所以我的导航控制器中有一个设置栏按钮项,当从家庭视图控制器按下时,会在家庭视图上打开设置vc透明视图,因此家庭vc仍然可以在设置vc后面看到.我希望导航栏仍然显示,所以在"HomeViewController.h"中我有以下代码:
-(IBAction)settingsButtonPressed:(id)sender{
SettingsViewController *settings = [[SettingsViewController alloc]init];
[self.navigationController.view addSubview:settings.view];
}
Run Code Online (Sandbox Code Playgroud)
当我想删除设置视图时,在"SettingsViewController"中我尝试了:
-(IBAction)exitSettings:(id)sender{
[self.navigationController.view removeFromSuperview];
}
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做并尝试运行程序时,程序停止,而在调试区域,它只是说
Thread 1: EXC_BAD_ACCESS (code = 2, address=0xb0000008)
(lldb)
Run Code Online (Sandbox Code Playgroud)
我做错了什么,如何解决这个问题?
有谁知道这条消息对Apple的意义:
"iPhone 5优化要求 - 您的二进制文件未针对iPhone 5进行优化.截至5月1日,所有提交的新iPhone应用程序和应用程序更新都必须支持iPhone 5上的4英寸显示屏.所有应用程序必须包含适当大小的启动图像通过查看iOS人机界面指南,了解有关iPhone 5支持的更多信息."
"无效的启动图像 - 您的应用程序包含一个启动图像,其尺寸修饰符仅支持使用iOS 6.0 SDK或更高版本构建的应用程序"
我使用的是Xcode Version 4.2和Base SDK 5.0
我创建的发布图像是这样的:
Default.png (320 x 480) Default@2x.png (640 x 960)Default-568h@2x.png (640 x 1136)在我的应用程序中,我想给动画UIButtons,就像按钮在隐藏时会"掉出"屏幕.
我尝试了以下代码,但它没有给我一个好结果.
[UIView animateWithDuration:1.5
animations:^{
S1Button.frame = CGRectMake(20, 10, 50, 10);
}];
[S1Button setHidden:YES];
break;
Run Code Online (Sandbox Code Playgroud) 我正在构建一个iphone应用程序,当我运行我的应用程序然后cellForRowAtIndexPath返回方法 时,我有一个包含99条记录的数组indexPath.row从0到7.这是我的代码如下
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[accountParser accounts]count];//it return 99 records
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
NSLog(@"Index : %d",indexPath.row);//this print index 0 to 7 only
}
return cell;
}
Run Code Online (Sandbox Code Playgroud) 在一个方法中,我需要读取一个NSArray或NSDictionary一个plist文件.
这是我的问题:当我不知道它是否是数组或字典时,如何从文件创建NSArrayOR ?NSDictionaryplist
我知道我可以做:
NSArray *myArray = [NSArray arrayWithContentsOfFile:filePath];
Run Code Online (Sandbox Code Playgroud)
要么
NSDictionary *myDico = [NSDictionary dictionaryWithContentsOfFile:filePath];
Run Code Online (Sandbox Code Playgroud)
但我不知道filePath是否包含a NSArray或a NSDictionary.我想要像:
id myObject = [... ...WithContentOfFile:filePath];
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我并给我最好的方法吗?
我有一个Web服务器,我曾经在我的iOS应用程序中获取一些数据.数据包括一个字段,itemId比如说'48501'(没有引用).我阅读商品JSON数据到我itemObject在其中itemId被定义为NSString,而不是一个NSInteger.
一切都有效,直到这一点,但我有问题,我想itemObject.itemId用isEqual:功能与另一个NSString填充的功能进行比较48501.
换句话说,两个字符串完全相同,并48501在我打印时包含.没有空间和隐藏的东西.全部isEqual:和isEqualToString:并且==在比较时报告错误.
当我转换NSStrings为NSIntegers并比较它时它起作用但并非总是如此!有时TRUECRASH没有错误捕获,只是指向该行!我看到它们打印完全相同,但if语句没有通过.
我向那些经验丰富的人展示了代码,他觉得这可能是一个错误!有没有人接触过这个?
虽然我们有很多人问同样的问题,但没有一个答案有助于解决我的问题.所以这是我的代码,
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *text = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"Response: %@", text);
//The NSJSONSerialization method to transform the NSData responseObject into a dictionnary does work
NSJSONSerialization *jsonResponse = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
//This NSLog makes the app crash with an unrecognized selector sent error
NSLog(@"JSON: %@",jsonResponse);
NSArray *result1=(NSArray *)[jsonResponse valueForKeyPath:@"result"];
NSLog(@"result1: %@",result1);
NSMutableString *shipPrice =[[NSMutableString alloc]init];
NSMutableString *freeLimitString =[[NSMutableString alloc]init];
if(result1!=Nil && ![result1 count]==0)
{
for (int i=0; i<result1.count; i++) …Run Code Online (Sandbox Code Playgroud) 我正在创建的扩展名UIFont,它给出了一个错误。我附上了它的屏幕截图。导入时此错误消失UIFont。
import Foundation
extension UIFont {
class func appRegularFont(with size:CGFloat) -> UIFont {
return UIFont(name:"HelveticaNeue-Bold", size: size)!
}
class func appMediumFont(with size:CGFloat) -> UIFont {
return UIFont(name:"HelveticaNeue-Bold", size: size)!
}
class func appBoldFont(with size:CGFloat) -> UIFont {
return UIFont(name:"HelveticaNeue-Bold", size: size)!
}
}
Run Code Online (Sandbox Code Playgroud)
ios ×6
objective-c ×3
iphone ×2
afnetworking ×1
animation ×1
json ×1
nsarray ×1
nsdictionary ×1
nsstring ×1
plist ×1
swift3 ×1
uitableview ×1
view ×1