在我的iPhone应用程序中,我有一个有4个按钮的动作表.
现在,为了执行单击这些按钮的操作,我已经实现了ActionSheet Delegate.
单击按钮时不会调用操作表委托方法.当集成到另一个项目时,相同的代码工作.
我已正确声明所有方法名称.
下面是显示委托方法的屏幕截图

可能有什么不对?
我在NSUserDefauts中存储和检索浮动时遇到问题.我存储了值,但是当我检索它时,它返回0.
这是我尝试过但没有用的东西:
[pref setFloat:3.0f forKey:@"key"];
float value = [pref floatForKey:@"key"]; //value=0
[pref setFloat:3 forKey:@"key"];
float value = [pref floatForKey:@"key"];//value=0
[pref setObject:[NSNumber numberWithFloat:3] forKey:@"key"];
float value = [[pref objectForKey:@"key"]floatValue];//value=0
[pref setObject:[NSNumber numberWithFloat:3.0f] forKey:@"key"];
float value = [[pref objectForKey:@"key"]floatValue];//value=0
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?我已经尝试了这4段代码,但是当从NSUserDefaults中检索浮动时它们都返回零.
任何帮助表示赞赏.谢谢!
我在我的应用程序中实现了Web服务.我的方式很典型.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Web Service xxx,yyy are not true data
NSString *urlString = @"http://xxx.byethost17.com/yyy";
NSURL *url = [NSURL URLWithString:urlString];
dispatch_async(kBackGroudQueue, ^{
NSData* data = [NSData dataWithContentsOfURL: url];
[self performSelectorOnMainThread:@selector(receiveLatest:) withObject:data waitUntilDone:YES];
});
return YES;
}
- (void)receiveLatest:(NSData *)responseData {
//parse out the json data
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions
error:&error];
NSString *Draw_539 = [json objectForKey:@"Draw_539"];
....
Run Code Online (Sandbox Code Playgroud)
控制台错误消息:
*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'data parameter is nil'
当我的iPhone连接到Internet时,该应用程序成功运行.但如果它断开连接到互联网,应用程序将崩溃NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
你能告诉我如何处理这个错误?有NSError帮助吗?
在我的iPhone应用程序中,我有一个ASCII艺术,它在两个字符之间有很多空格.
所以我需要为每个空格添加空间的转义序列.
iPhone SDK中的空间转义序列是什么?
我在ASIFormDataRequest中苦苦挣扎.
我想在iphone上的facebook上传一张照片,以便我在编程中使用ASIFormDataRequest,但它给出了我的错误 _OBJC_CLASS_$_ASIFormDataRequest,参考:
我不明白它的含义,我该如何处理它
我上传照片的代码如下:
-(void)postphoto:(id)sender
{
UISegmentedControl* _segControl;
//ASIFormDataRequest *request;
UIImageView *_imageView = [UIImageView alloc];// initWithImage: image];
NSString *likeString;
NSString *filePath = nil;
if (_imageView.image == [UIImage imageNamed:@"angelina.jpg"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"angelina" ofType:@"jpg"];
likeString = @"babe";
} else if (_imageView.image == [UIImage imageNamed:@"depp.jpg"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"depp" ofType:@"jpg"];
likeString = @"dude";
} else if (_imageView.image == [UIImage imageNamed:@"maltese.jpg"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"maltese" ofType:@"jpg"];
likeString = @"puppy";
}
if (filePath == nil) return; …Run Code Online (Sandbox Code Playgroud) 我正在使用NSXMLParser来解析从我的webservice中获取的数据.但是当我从服务器获取数据时.
它给了我错误代码5.
我无法看到来自Web服务的响应.
我用
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:theURL];
Run Code Online (Sandbox Code Playgroud)
但是当我写作时,我无法在控制台中看到响应 NSLog(@"%@",parser);
如何显示从我的Web服务获得的响应?
在iPhone应用程序中,当valueforKey是ENUM时,如何在控制台中显示用户默认值的值?
目前使用以下代码,如果我尝试在控制台中显示,那么它会在控制台中没有崩溃日志而崩溃.
NSLog(@"%@",[[NSUserDefaults standardUserDefaults] valueForKey:Enum]);
Run Code Online (Sandbox Code Playgroud) 如何将NSNumber"1234567"转换为"12,34,567"?
我已经使用了NSNumberFormatter,但无法获得所需的结果.
我这样做
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSString *formattedString = [formatter stringFromNumber:[NSNumber numberWithFloat:1234567]];
NSLog(@":%@",formattedString);
Run Code Online (Sandbox Code Playgroud)
产量:1,234,567
期望的产出:12,34,567
我有一个像这样的NSMutableArray:
(
{
City = "Orlando";
Name = "Shoreline Dental";
State = Florida;
},
{
City = "Alabaster ";
Name = Oxford Multispeciality;
State = Alabama;
},
{
City = Dallas;
Name = "Williams Spa";
State = Texas;
},
{
City = "Orlando ";
Name = "Roast Street";
State = Florida;
}
)
Run Code Online (Sandbox Code Playgroud)
现在,我如何对这个NSMutableArray进行排序,以获得与我希望获得的状态"佛罗里达"相对应的结果
(
{
City = "Orlando";
Name = "Shoreline Dental";
State = Florida;
},
{
City = "Orlando ";
Name = "Roast Street";
State = Florida;
} …Run Code Online (Sandbox Code Playgroud) 我需要的:
1)从库或相机中选择图像
2)写和文字
3)文字被裁剪成图像!
下面的图片可以更清楚地说明我需要什么.

我知道屏蔽和裁剪图像,即使我在emoji me app中使用框架进行遮罩.我只需要知道如何根据动态文本裁剪图像.
请提出你的建议.
...
UIImage *image = [UIImage imageNamed:@"dogs.png"];
UIImage *mask = [UIImage imageNamed:@"mask.png"];
// result of the masking method
UIImage *maskedImage = [self maskImage:image withMask:mask];
...
- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage {
CGImageRef maskRef = maskImage.CGImage;
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
CGImageRef maskedImageRef = CGImageCreateWithMask([image CGImage], mask);
UIImage *maskedImage = [UIImage imageWithCGImage:maskedImageRef];
CGImageRelease(mask);
CGImageRelease(maskedImageRef);
// returns new image with mask applied
return maskedImage;
}
Run Code Online (Sandbox Code Playgroud) iphone ×10
objective-c ×8
ios ×5
ios4 ×5
cocoa-touch ×3
xcode ×2
json ×1
nsxmlparser ×1
web-services ×1
xcode4.5 ×1
xml ×1