我在纵向模式下拥有所有应用程序,但我在横向模式下有一个viewcontroller是图像库.
在项目摘要选项卡上启用LandscapeLeft模式,所以我必须在ViewController的其余部分禁用旋转,除了在图像库的VC中.
我想在纵向模式下保持旋转,要执行此操作并阻止所有VC纵向,我使用以下代码
-(BOOL)shouldAutorotate{
return YES;
}
-(NSInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
}
return UIInterfaceOrientationPortrait;
}
Run Code Online (Sandbox Code Playgroud)
这个,让我在之前的VC中保持横向模式,它应该旋转到Portrait.
有什么想法吗?
我有一个UIActionSheet来更改UITextView的字体.我的问题是我已经添加了另一个UITextView,现在想要它取决于打开的UITextView,(我的意思是打开编辑,显示键盘)给我一个源的类型在一个或另一个...不是哪个是UITextView的正确属性,以便根据选择区分彼此.
任何的想法?
这是单个UITextView的情况.
- (IBAction) displayFontPicker:(id)sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select a font" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Helvetica", @"Courier", @"Arial", @"Zapfino", @"Verdana", nil];
[actionSheet showFromBarButtonItem:(UIBarButtonItem *)sender animated:YES];
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *selectedButtonTitle = [actionSheet buttonTitleAtIndex:buttonIndex];
selectedButtonTitle = [selectedButtonTitle lowercaseString];
if ([actionSheet.title isEqualToString:@"Select a font"])
switch (buttonIndex){
case 0:
[_textView setFont:[UIFont fontWithName:@"Helvetica" size:25]];
break;
case 1:
[_textView setFont:[UIFont fontWithName:@"Courier" size:25]];
break;
}
Run Code Online (Sandbox Code Playgroud)
我看到使用textview,可以使用多种方法,特别是这可以使用它,将在你开始编辑textview时运行.
(void)textViewDidBeginEditing:(UITextView *)textView
Run Code Online (Sandbox Code Playgroud)
但我不知道如何在我的代码中实现它...