我想在EAGLView上的特定触摸点获得Pixel的颜色.这是可能的,如果是的话,怎么样?
我目前从'Documents'目录中获取图像(使用-imageWithContentsOfFile :)没有任何问题,除了我无法立即显示图像(例如,一旦调用touchesEnded).我假设这与图像缓存有关,并且以上述方式创建的图像对象不会被缓存?所以,我想,我会在创建后缓存图像对象,然后使用-imageNamed:来使用缓存的图像.那么如何将UIImage对象保存到应用程序的Bundle和/或Cache呢?
我正在释放东西,但根据乐器,记忆似乎依旧存在.我只是发布指针而不是实际数据吗?如何在objective-c中发布数据?[anObject release]或者有[&anObject release]什么区别?
请原谅我对记忆和指针主题缺乏了解.
我试图对像素进行迭代,以在不使用OpenGL的情况下更改UIImage的RGBA值.我尝试使用下面的代码测试迭代性能,但非常不满意.好像我每秒只能进行几千次迭代.而对于具有数十万像素的UIImage,这将花费太长时间......任何人都对如何提高性能或这些操作通常需要多长时间有任何建议?
-(UIImage*)modifyPixels:(UIImage*)originalImage
{
NSData* pixelData = (NSData*)CGDataProviderCopyData(CGImageGetDataProvider(originalImage.CGImage));
void* pixelBytes = [pixelData bytes];
// Take away the red pixel, assuming 32-bit RGBA
for(int i = 0; i < [pixelData length]; i += 4) {
NSLog(@" %ith iteration (%i / %i / %i / %i)", i, pixelData[i], pixelData[i+1], pixelData[i+2], pixelData[i+3]);
}
//NSData* newPixelData = [NSData dataWithBytes:pixelBytes length:[pixelData length]];
//UIImage* newImage = [UIImage imageWithData:newPixelData];
return originalImage;
}
Run Code Online (Sandbox Code Playgroud) 我在尝试使用NSDateFormatter时收到此警告(如下所示).我在我的.h文件中导入所以问题是什么?(哦,同样的方法会产生错误(无法识别的选择器发送...))
这是警告:
warning: no '-initWithDateFormat:allowNaturalLanguage:' method found
Run Code Online (Sandbox Code Playgroud)
这是代码:
NSDateFormatter *myFormatter = [[NSDateFormatter alloc] initWithDateFormat:@"EEE, dd, MMM yyyy HH:mm:ss ZZZ" allowNaturalLanguage:NO];
NSDate *date = [myFormatter dateFromString:@"Mon, 01 Feb 2010 20:25:37 +0000"];
NSLog(@"Time interval %d",[date timeIntervalSinceNow]);
Run Code Online (Sandbox Code Playgroud) 我有四个UINavigationControllers分配给UITabBarController中的一个选项卡.每个UINavigationController都管理一个UIViewController,它本身可以分支到它下面的其他UIViewControllers.
我的问题是,如果用户在一个选项卡下导航到UIViewController,该UIViewController低于UINavigationController管理的主UIViewController,然后用户推送另一个选项卡,然后返回原始选项卡,我如何才能使用户看到由UINavigation控制器管理的主UIViewController?而不是他离开的页面?
UITabBarController在IB中设置
iphone xcode uitabbarcontroller uiviewcontroller uinavigationcontroller
我得到这个链接器错误,不会让我编译.它只发生在模拟器上.
要点:
-只发生在模拟器
-以类似这个问题,却发现我的.pbxproj文件中没有FRAMEWORK_SEARCH_PATHS
-虽然我的操作系统是10.6.2,我必须建立目标1.5,以避免其他链接错误
- libxml2.dylib IS必需的,在我的框架组
- 我从未听说过的其他引用的库.
- 尝试在框架下引入其他Libs,没有解决.
Build SpaceTweet of project SpaceTweet with configuration Debug
Ld build/Debug-iphonesimulator/SpaceTweet.app/SpaceTweet normal i386
cd "/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)"
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk "-L/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/build/Debug-iphonesimulator" -L/Users/Scott/Desktop "-L/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/../../libYAJLIPhone-0" -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib -L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/usr/lib -L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib "-F/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/build/Debug-iphonesimulator" -filelist "/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/build/SpaceTweet.build/Debug-iphonesimulator/SpaceTweet.build/Objects-normal/i386/SpaceTweet.LinkFileList" -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -framework AVFoundation -framework MessageUI -lYAJLIPhone -lxml2 -o "/Users/Scott/Desktop/iPhone Dev/SpaceTweet(Experimental)/build/Debug-iphonesimulator/SpaceTweet.app/SpaceTweet"
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/libxml2.dylib, missing required architecture i386 in file …Run Code Online (Sandbox Code Playgroud) compiler-construction iphone xcode osx-snow-leopard ios-simulator
如何在iPhone Twitter应用程序(MGTwitterEngine)上进行RETWEET
我的主视图控制器(代表我的应用程序中的主菜单)有一个简单的UIView,带有一些子视图.我正在使用模态类型的设计模式,并在最终返回主菜单之前切换到多个其他视图控制器.问题是,在我的其他视图控制器(不是主菜单)中,我经常加载数据量大的图像等有时会导致主菜单(当前不在屏幕上)卸载其视图以响应记忆警告.问题是,当我最终切换回我的主菜单时,屏幕全是黑色的,除了几个UILabel之外都已经取消了.此时,我想重新加载我的视图并重新开始.但是在文档中,它说你永远不应该直接调用-loadView.如何重新加载我的视图?
我无法将C数组声明为Objective-C属性(你知道@property和@synthesize所以我可以使用点语法)......它只是一个3维int数组..
NSFilemanager在以下情况下返回true,此时不应该有任何此类文件.怎么了?
if([myManager fileExistsAtPath:[[self documentsDirectory] stringByAppendingPathComponent:@"Music/songlist.txt"]]){
NSLog(@"file is there");
}
Run Code Online (Sandbox Code Playgroud)