我想在iPhone 4S上测试我的应用程序.当我从Xcode构建并运行时,项目已成功编译,但在此之后Xcode说:
在MyiPhone上完成运行MyApp.app
该应用程序完美地在模拟器上工作,配置文件正常工作(我试图加载一个空的应用程序,它的工作原理).
如果我尝试手动加载应用程序,我会收到以下消息:
位于/ Users/* /Documents/App/AppName/DerivedData/AppName/Build/Products/Release-iphoneos/AppName.app的应用程序的Info.plist 指定了AppName的CFBundleExecutable,它不存在.
问题出在哪儿?
我要将我的应用程序更新到新的4英寸显示屏,我发现我应该检查检查器中的Use Autolayout复选框.这样做我失去了与iOs 5的兼容性.如何在不失去这种兼容性的情况下支持4"显示器?非常感谢你.
objective-c backwards-compatibility ios5 uistoryboard iphone-5
我试图动态创建基于长期NSAttributedString分割成多个部分的书页.
我现在正在做的是使用此类别NSAttributedString:
@interface NSAttributedString (Height)
- (CGFloat)boundingHeightForWidth:(CGFloat)inWidth;
@end
@implementation NSAttributedString (Height)
- (CGFloat)boundingHeightForWidth:(CGFloat)inWidth
{
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFMutableAttributedStringRef)self);
CGSize suggestedSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, 0), NULL, CGSizeMake(inWidth, 10000), NULL);
CFRelease(framesetter);
return suggestedSize.height ;
}
@end
Run Code Online (Sandbox Code Playgroud)
由于我使用a绘制文本CTFramesetter,因此工作正常并且正确返回了正确的框高度.不幸的是现在我需要逐行绘制文本:
-(void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
// Flip the coordinate system
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
//CGContextTranslateCTM(context, 0, self.bounds.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
NSArray *lines = (__bridge NSArray *)(CTFrameGetLines(ctFrame));
CFIndex lineCount = [lines count];
for(CFIndex idx = 0; idx < lineCount; idx++)
{ …Run Code Online (Sandbox Code Playgroud) 我有一个Constants.h文件,其实际上包含一些全局常量.由于我的应用程序是为iPhone和iPad构建的,我想为两种设备类型定义相同的常量(即具有相同的名称).
有关完整说明:
/******** pseudo code *********/
if (deviceIsIPad){
#define kPageMargin 20
}
else {
#define kPageMargin 10
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?谢谢.
L.
我正在尝试在我的项目中使用此字体,但它不起作用.我在我的项目中添加了.ttf文件,并在MyApp-Info.plist中的密钥下添加了它的名称:应用程序提供的字体.然后我尝试了这个:
[_titleLabel setFont:[UIFont fontWithName:@"chalkboard" size:_titleLabel.font.pointSize]];
Run Code Online (Sandbox Code Playgroud)
我还检查了字体的名称是否真的是"黑板",它是.显示的字体仍然是Helvetica,只是更小.问题出在哪里?提前致谢.
我正在尝试在应用程序关闭时在简单的.plist文件上保存一个简单的字符串.
这是我的代码:
- (void)viewDidLoad {
NSString *filePath = [self dataFilePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:filePath];
self.kmOld.text = [array objectAtIndex:0];
[array release];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification
object:NULL];
[super viewDidLoad];
Run Code Online (Sandbox Code Playgroud)
}
然后按照applicationWillResignActive方法操作:
- (void)applicationWillResignActive:(NSNotification *)notification {
NSString *text = [[NSString alloc]initWithFormat:@"%@",kmNew.text];
NSLog(@"%@",text);
if ([text intValue]>0) {
NSArray *array = [[NSArray alloc] initWithObjects:text, nil];
BOOL success = [array writeToFile:[self dataFilePath] atomically:YES];
NSLog(@"%d",success);
[array release];
}
[text release];
}
Run Code Online (Sandbox Code Playgroud)
这在模拟器上运行良好,但设备似乎忽略了......问题出在哪里?谢谢...
我想知道如何从完成的ASIHTTPRequest中检索post值.
当我执行请求时,我这样做:
[request setPostValue:uniqueID forKey:@"bookUniqueId"];
NSFileManager *fileManager = [[NSFileManager alloc]init];
if (![fileManager fileExistsAtPath:tempDir]) {
[fileManager createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:nil];
}
[fileManager release];
tempDir = [[tempDir stringByAppendingPathComponent:uniqueID]stringByAppendingPathExtension:@"zip"];
[request setDownloadDestinationPath:tempDir];
[request setDelegate:self];
[request startAsynchronous];
Run Code Online (Sandbox Code Playgroud)
因为我想下载zip文件,名字就像我书的ID.
在- (void)requestFinished:(ASIHTTPRequest *)request方法中,我需要该ID来解压缩文件.我无法将ID保存在ivar中,因为我想支持多个异步下载.
我怎样才能做到这一点?有没有类似于不存在的方法[request postValueForKey: key]?
我正在尝试增强非ARC应用程序中的内存分配.有些对象即使引用计数为0,也会在两个快照之间列为持久对象.
这是我的快照视图: 
让我们在第一个快照(0x6deb180)中选择所选的LSBookChapter.这是该对象的历史:

为什么该对象没有被释放?如果引用计数为0,我无法弄清楚当我保留该对象时..
我正在使用两个不同的TapGestureRecognizer来处理屏幕上的单击和双击.这是代码:
UITapGestureRecognizer *tapGR =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
[tapGR setDelegate:self];
[tapGR setNumberOfTapsRequired:1];
[self addGestureRecognizer:tapGR];
UITapGestureRecognizer *doubleTapGR = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTapGR setNumberOfTouchesRequired:2];
[self addGestureRecognizer:doubleTapGR];
[tapGR requireGestureRecognizerToFail : doubleTapGR];
[tapGR release];
[doubleTapGR release];
Run Code Online (Sandbox Code Playgroud)
即使我指定了[tapGR requireGestureRecognizerToFail:doubleTapGR],也会执行"handleTap"选择器.哪里出错了?
我写了下面这段代码:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
GameViewController *gameViewController = [[GameViewController alloc]initWithLevelNumber:([levelGroup intValue]*100+indexPath.row) Bonus:NO];
NSLog(@"Retain Counter =%d",gameViewController.retainCount);
[navController pushViewController:gameViewController animated:YES];
[gameViewController release];
NSLog(@"Retain Counter=%d",gameViewController.retainCount);
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
两个日志的结果按顺序1和6!这怎么可能?我只调用一次alloc方法并在将控制器推到堆栈后释放.. alloc-> + 1,push-> + 1,release-> -1 = 1或不?
当我将它从堆栈中弹出时,我希望视图控制器是dealloc'd ..
objective-c uinavigationcontroller pushviewcontroller ios retaincount
objective-c ×8
ios ×6
iphone ×5
ipad ×3
device ×2
ios5 ×2
constants ×1
core-text ×1
custom-font ×1
definition ×1
instruments ×1
iphone-5 ×1
memory-leaks ×1
retaincount ×1
uilabel ×1
uistoryboard ×1
xcode ×1
xcode4.3 ×1