这就是我要设置的最大行数:
#include "A.h"
A<int,int,int,int> a;
a.method1();
当第3行即将开始时,光标消失。要把它放回去,我必须点击退格键。
答案 0 :(得分:3)
假设在文本视图中光标不会留在键盘后面。我编写了一个帮助方法,使UITextField文本滚动到文本结尾。
- (void)scrollToCaretInTextView:(UITextView *)textView animated:(BOOL)animated
{
CGRect rect = [textView caretRectForPosition:textView.selectedTextRange.end]; //Get the content size of textview
rect.size.height += textView.textContainerInset.bottom;
[textView scrollRectToVisible:rect animated:animated];
}
答案 1 :(得分:2)
我不太确定你的期望。如果你想要最多两行,那么应该没有第三行。
使用此:
import { TestBed, async, inject } from '@angular/core/testing';
import { SignupService } from './signup.service';
import { Observable } from 'rxjs/Observable';
import { HttpModule, Http, Response, ResponseOptions, RequestOptions, Headers, XHRBackend } from '@angular/http';
import { MockBackend, MockConnection } from '@angular/http/testing';
import { ErrorHandlerService } from '../../services/error-handler.service';
describe('SignupService', () => {
let errorStub = {};
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule],
providers: [
SignupService,
{ provide: XHRBackend, useClass: MockBackend },
{ provide: ErrorHandlerService, useValue: errorStub }
]
});
});
it('signup should return an application error if no apps are provided', inject([SignupService], (service: SignupService) => {
service.signup('', [], null).subscribe(
suc => { },
err => expect(err).toMatch(/application/)
);
}));
it('signup should return a role error if no roles are provided', inject([SignupService], (service: SignupService) => {
service.signup('', null, []).subscribe(
suc => { },
err => expect(err).toMatch(/rôle/)
);
}));
it(
'signup should return a response with a "contenu" parameter',
inject([SignupService, XHRBackend], (service: SignupService, mockBackEnd: MockBackend) => {
let content = 'anything';
mockBackEnd.connections.subscribe((connection: MockConnection) => {
connection.mockRespond(new Response(new ResponseOptions({
body: JSON.stringify({
contenu: content
})
})));
});
service.signup('', [], []).subscribe(
suc => expect(suc).toBe(content)
);
}));
it(
'checkUser should return a response with a "contenu" parameter',
inject([SignupService, XHRBackend], (service: SignupService, mockBackEnd: MockBackend) => {
let content = 'anything';
mockBackEnd.connections.subscribe((connection: MockConnection) => {
connection.mockRespond(new Response(new ResponseOptions({
body: JSON.stringify({
contenu: content
})
})));
});
service.checkUser('').subscribe(
suc => expect(suc).toBe(content)
);
}));
});
Limit the number of lines for UITextview
看起来你真正想要的是一个有两行高度的textview?如果是这样,请在查看控制器时尝试此操作。
self.text_description.textContainer.maximumNumberOfLines = 2
self.text_description.textContainer.lineBreakMode = .byTruncatingTail