小编JSA*_*986的帖子

如何在呈现第二个警报视图之前添加延迟

我一个接一个地连续显示两个警报视图,具体如下:

-IBAction

UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"my message"     delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert setDelegate:self];

[alert show];




}

- (void)didPresentAlertView:(UIAlertView *)alertView 
{

[alertView setTitle:@"My new title"];
[alertView setMessage:@"My new message"];

}
Run Code Online (Sandbox Code Playgroud)

从第一个警报视图到第二个警报视图的转换速度非常快,用户没有时间阅读第一条消息.有人可以建议如何在警报之间添加延迟.我想我需要实现一个NSTimer,但实现这个我可以使用一些建议.

uialertview ios

1
推荐指数
1
解决办法
4265
查看次数

UIPicker错误[__NSCFConstantString _isResizable] :?

UI Pickers让我再次陷入困境,我仍在学习UI选择器,所以不确定我是否在这里做了一些根本错误的事情.

试图从行UIPicker显示图像.

错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString _isResizable]: unrecognized selector sent to instance 0x70fc' *** First throw call stack:

下面是代码:

#import "Imagepick.h"

@interface Imagepick ()

@end

@implementation Imagepick
 @synthesize select;
@synthesize imageview;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

- (void)viewDidLoad
{


   ////arrays & objects
   arrStatus = [[NSArray alloc] initWithObjects:@"pic1",@"pic2",nil];




}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
//One column
return 1;
} …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c uipickerview ios

1
推荐指数
1
解决办法
2111
查看次数

AnyObject没有名为"sort"的成员

我有一个数组var savedDataArray: AnyObject? = NSUserDefaults.standardUserDefaults().objectForKey("savedDataArray")G,我想升序排序

我检查它是否为空,然后解开它,但是我仍然得到"没有名字成员"的错误?

if savedDataArray?.count>0{
            savedDataArray!.sort{$0.localizedCaseInsensitiveCompare($1) == NSComparisonResult.OrderedAscending }
        }
Run Code Online (Sandbox Code Playgroud)

错误 Any object does not have a member named "sort"

所以,然后我尝试扭转array和大惊喜相同的错误.reverse

我想通过检查数组是否nil,然后强制解包,这些错误不相关

arrays sorting ios swift

1
推荐指数
1
解决办法
221
查看次数

实现声音时黄色警告三角形我不明白

当我在我的应用程序中实现声音时,我总是会发出几个带有警告的黄色警告三角形:

"隐式声明功能"音频服务创建系统soundID"在C99中无效"

它在我的应用程序中没有任何影响我只是想知道它是否在我的代码中,我应该解决的问题?

CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"btnclick", CFSTR 
                                        ("mp3"), NULL);
                                        UInt32 soundID;
                                        AudioServicesCreateSystemSoundID (soundFileURLRef, &soundID);
                                        AudioServicesPlaySystemSound (soundID);
Run Code Online (Sandbox Code Playgroud)

audio ios5 xcode4.3

0
推荐指数
1
解决办法
972
查看次数

UIAlertView展示一次

我知道这可能听起来很奇怪,我已经在以前的应用程序中工作,现在在我现在的应用程序不能使用相同的代码工作.我试图在应用程序启动时显示一次警报视图uisng:

 if (![@"1" isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"alert"]]){

    [[NSUserDefaults standardUserDefaults] setValue:@"1" forKey:@"alert"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}



 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:@"Text here" delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];

[alert show];
Run Code Online (Sandbox Code Playgroud)

有人会介意检查我已经在这里做了一些愚蠢的事情,我已经在我的应用程序中交叉检查它,这是有效的,所有看起来都是一样的.

xcode objective-c uialertview ios

0
推荐指数
1
解决办法
1933
查看次数

只有在首次启动应用时,随机数选择器才会选择相同的数字

我使用生成一个随机数字符串

int rNumber = rand() %100000000 + 1;
_certificateReferenceField.text = [[NSString alloc] initWithFormat: @"C/R %d", rNumber];
Run Code Online (Sandbox Code Playgroud)

当应用程序首次启动或来自后台时,它始终会选择相同的号码c/R16808?再次按它没问题,一切正常.

cocoa-touch objective-c ios

0
推荐指数
1
解决办法
190
查看次数

如果需要声明建议

我想,当我输入大于200的值,显示一个警告UITextField,rcdAtIan.text.我试过这个:

 Self.rcdAtIan.text = self.circuit.rcdAtIan;
    if (_rcdAtIan.text > @"200");{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Value Exceeded" message:@"Message here............." delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
           [alert show];
Run Code Online (Sandbox Code Playgroud)

然后这个:

Self.rcdAtIan.text = self.circuit.rcdAtIan;
 if (self.circuit.rcdAtIan > @"200");{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Value Exceeded" message:@"Message here.........." delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
           [alert show];
    }
Run Code Online (Sandbox Code Playgroud)

但是加载视图时会显示警报,而不是我的if声明.我知道我想说的是什么if (_rcdAtIan.text => 200 "show my alert");- 但我不确定正确的语法.

cocoa-touch objective-c ios

0
推荐指数
1
解决办法
64
查看次数

如果allowsEditing = NO,Picker不会返回任何图像

如标题所示,如果我设定

imagePickerController.allowsEditing = YES;

imagePickerController.allowsEditing = NO

我没有返回图片?我搜索过SO并找不到明确的答案

    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.delegate = self;
    imagePicker.allowsEditing = NO;
    [self.editController presentModalViewController:imagePicker animated:YES];


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  DebugLog(@"info dict: %@", info);
  [picker dismissModalViewControllerAnimated:YES];
  UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
  self.schemeLogo.backgroundColor = [UIColor whiteColor];
  self.schemeLogo.image = image;
  NSData *imageData1 = UIImagePNGRepresentation(image);
  NSString *path1 = [ICUtils pathForDocument:@"schemeLogo.png"];
  [imageData1 writeToFile:path1 atomically:NO];
}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c ios

0
推荐指数
1
解决办法
1006
查看次数

使用#define,好的做法?

为了清理我的代码,使用#define多行代码是一种好习惯吗?大多数示例都是几行,定义了维度等.
在我的示例中,我有以下代码段的单独头文件.使用#define这种方式是好的做法吗?

#define KCHECKREFERENCE if([self.partClasses containsObject:@"Part1"]||[self.partClasses containsObject:@"Part2"]||[self.partClasses containsObject:@"Part3"]||[self.partClasses containsObject:@"Part4"]||[self.partClasses containsObject:@"Part5"]||[self.partClasses containsObject:@"Part6"]||[self.partClasses containsObject:@"ICDomesticEICPart7"]||[self.partClasses containsObject:@"ICDomesticEICPart8"] ){\
[self.currentPartView save];\
self.previousPartView = self.currentPartView;\
int nextPartNumber = 1;\
ICCertificateComponent *part = [self loadPart:nextPartNumber];\
self.currentPartView = part;\
CGRect nextPartViewFrame = self.currentPartView.view.frame;\
nextPartViewFrame.origin.x = 320.0f;\
self.currentPartView.view.frame = nextPartViewFrame;\
CGRect previousPartViewFrame = self.previousPartView.view.frame;\
previousPartViewFrame.origin.x = -320.0f;\
nextPartViewFrame.origin.x = 0;\
[self.view insertSubview:self.currentPartView.view belowSubview:self.navBarView];\
NSTimeInterval duration = 0.1;\
[UIView animateWithDuration:duration\
                 animations:^{\
                     self.previousPartView.view.frame = previousPartViewFrame;\
                     self.currentPartView.view.frame = nextPartViewFrame;\
                 }\
                 completion:^(BOOL finished) {\
                     self.currentPartNumber = 1;\
                     self.navBarView.prevButton.enabled = …
Run Code Online (Sandbox Code Playgroud)

macros objective-c ios

0
推荐指数
1
解决办法
102
查看次数