在我的课堂上,我需要有2个不同的(或更多)动作表.所有工作表都转到willPresentActionSheet.在willPresentActionSheet中,我会添加一个datepicker.但是我怎么知道哪个动作表叫做willPresentActionSheet?
编辑:我创建了这样的动作表:
UIActionSheet *asheet = [[UIActionSheet alloc]
initWithTitle:@"Pick a value"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Select"
, nil];
[asheet showInView:[self.view superview]];
[asheet setFrame:CGRectMake(0, 117, 320, 383)];
[asheet release];
Run Code Online (Sandbox Code Playgroud) 我在导航堆栈上弹出一些视图控制器后出现此错误,最后我通过操作表询问问题.我得到的错误参数不满意view != nil,这让我发疯,因为它nil在我调用动作表之前检查时不是一个值.
if (self.view != nil) {
NSLog(@"view is not nil");
}
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"title" delegate:nil cancelButtonTitle:@"cancel" destructiveButtonTitle:@"destructive" otherButtonTitles:nil];
[actionSheet showInView:self.view];
Run Code Online (Sandbox Code Playgroud) cocoa-touch uiviewcontroller uiview uinavigationcontroller uiactionsheet
使用Xcode我有View A导航到View B.
在按下Back UIBarButtonItem时,我正在尝试向用户显示UIActionSheet以确认导航以返回到View A.
在代码中我需要做什么来阻止视图导航回来然后(取决于用户输入)向后移动或留在当前屏幕上?
我有以下代码生成UICollectionView.当您在UICollectionViewCell上长按时,会出现UIActionSheet.
这有效,但只有一次.如果您关闭UIActionSheet并再次长按同一个单元格,则不会发生任何事情.
我有什么想法我做错了吗?
#import "ProjectsListViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface ProjectsListViewController ()
@end
@implementation ProjectsListViewController
@synthesize appDelegate;
- (void)viewDidLoad
{
[super viewDidLoad];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
// CREATE THE COLLECTION VIEW
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[self setCollectionView:[[UICollectionView alloc] initWithFrame:CGRectMake(20, 54, [[self view] bounds].size.width - 40, [[self view] bounds].size.height) collectionViewLayout:flowLayout]];
[[self collectionView] setDataSource:self];
[[self collectionView] setDelegate:self];
[self.view addSubview:self.collectionView];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
[[self collectionView] setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section
{
return [[[appDelegate userSettingsDictionary] objectForKey:@"Projects"] count];
}
- (NSInteger)numberOfSectionsInCollectionView: …Run Code Online (Sandbox Code Playgroud) 我有一个在iPad上UIActionSheet显示UIPopoverController的.我试图UIButton通过使用以下方式显示它:
[self.exampleActionSheet showFromRect:self.exampleButton.frame inView:self.view animated:YES];
我现在要做的是UIActionSheet在方向改变上重新定位.但是当我在屏幕旋转后使用上面的代码重新定位时,它不会这样做.谁能告诉我如何正确地做到这一点?
在iOS 8,代码崩溃后添加图像UIActionSheet's _button valueForKey.
UIActionSheet *action = [[UIActionSheet alloc ] initWithTitle:@"Choose Action!" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Start Auto Scroll", nil];
[[[action valueForKey:@"_buttons"] objectAtIndex:0] setImage:[UIImage imageNamed:@"autoScroll.png"] forState:UIControlStateNormal];
[action showInView:self.view];
Run Code Online (Sandbox Code Playgroud)
崩溃日志是
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIActionSheet 0x7ff6d8c61030> valueForUndefinedKey:]: this class is not key value coding-compliant for the key _buttons.'
Run Code Online (Sandbox Code Playgroud)
我怎么解决呢?
许多应用程序使用一个小的中心黑色圆角矩形,当一个动作被调用以保存网络的东西,通常包含一个throbber.
他们在ios中叫什么?UIActionSheets?
当我想保存某些东西时,如何创建一个?
我有一个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)
但我不知道如何在我的代码中实现它...
ios ×6
objective-c ×4
ios8 ×2
iphone ×2
cocoa-touch ×1
ios7 ×1
ipad ×1
navigation ×1
swift ×1
uitextview ×1
uiview ×1
xcode ×1