Tag: 目标C

iOS以编程方式显示基于当前用户的视图控制器

我有一个PreferencesViewController显示有关当前用户的信息: 但这取决于当前的用户。 如果用户还没有login,我正在使用PreferencesViewController viewWillAppear方法触发LoginViewController继续: 如果用户尚未login并再次点击“ Preferences选项” Preferences卡,就会出现问题。 它将segue退回到PreferencesViewController ,导致意外的行为( PreferencesViewController应该只在用户login时呈现) 什么是解决这个问题的最好方法? 我正在使用的方法可以吗? 它可以更优化吗?

从安装地图的数组中检索信息(MapKit)

我有一个数组字典。 在每个字典中我都有一些信息。 我想在地图上为arrays中的每个项目添加一个点。 我没有任何东西,但没有selectForAnnotation方法,我怎么进入数组内部作为该对象的某些信息? 在表中,我将使用indexPath,但注释没有该indexPath。 有没有解决scheme?

核心图:轴交替填充自定义轴标签

我正在使用Core Plot库在iOS上绘制graphics。 我想在yAxis的网格线之间添加颜色。 我已经设法做到这一点,设置轴的alternatingBandFills属性。 不过,我也必须在yAxis上使用自定义标签,当我提供自定义标签时,alternatingBandFills属性由于某种原因而不起作用。 任何帮助如何将颜色添加到网格线之间的空间yAxis以及使用自定义标签将不胜感激。 我现在使用的代码如下所示: CPTXYAxisSet *axisSet = (CPTXYAxisSet *)self.hostedGraph.axisSet; CPTXYAxis *yAxis = axisSet.yAxis; yAxis.orthogonalCoordinateDecimal = CPTDecimalFromDouble(minValueX); yAxis.labelingPolicy = CPTAxisLabelingPolicyNone; NSArray *yAxisTickLocations = [NSArray arrayWithObjects: [NSDecimalNumber numberWithDouble:lowerRedRangeFrom], [NSDecimalNumber numberWithDouble:lowerOrangeRangeFrom], [NSDecimalNumber numberWithDouble:greenRangeFrom], [NSDecimalNumber numberWithDouble:upperOrangeRangeFrom], [NSDecimalNumber numberWithDouble:upperRedRangeFrom], [NSDecimalNumber numberWithDouble:upperRedRangeTo], nil]; NSArray *yAxisLabels = [NSArray arrayWithObjects:@"Label1",@"Label2", @"Label3",@"Label4",@"Label5",@"Label6", nil]; NSUInteger labelLocationY = 0; NSMutableArray *customLabelsY = [NSMutableArray […]

邮件和消息不会从警报视图中消失

我有一个UIAlertView启动一个电子邮件和消息屏幕。 当用户点击警报button时,两个视图都打开,但是它们不closures。 我有一个尝试添加: -(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { [self dismissModalViewControllerAnimated:YES]; } 对class级的身体来说却没有帮助。 以下是电子邮件的介绍: [viewController presentViewController:email animated:YES completion:nil]; 编辑这里是我用来显示电子邮件的整个代码: //send email… -(void)sendEmail{ //mail composer Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); if(mailClass != nil){ if([mailClass canSendMail]){ //get the current view controller from the App Delegate apptester_appDelegate *appDelegate = (apptester_appDelegate *)[[UIApplication sharedApplication] delegate]; UIViewController *viewController = [appDelegate getViewController]; MFMailComposeViewController *email = […]

编译OpenCV for iOS失败 – Cmake失败

我尝试为ios编译OpenCV。 我总是得到这些错误。 我尝试了不同版本的opencv,但结果是一样的。 我运行这个:python平台/ ios / build_framework.py ios_opencv_build 我安装了python,cmake和g ++编译器。 有没有人有一个想法这些错误是什么意思,我应该做什么编译成功? — Setting up iPhoneOS toolchain — iPhoneOS toolchain loaded — Setting up iPhoneOS toolchain — iPhoneOS toolchain loaded — The CXX compiler identification is Clang 5.1.0 — The C compiler identification is Clang 5.1.0 — Performing Test HAVE_CXX_FSIGNED_CHAR CMake Error at /opt/local/share/cmake-2.8/Modules/CMakeCXXInformation.cmake:37 (get_filename_component): get_filename_component […]

如何从目标c中的静态方法调用非静态方法?

我有一个类,我正在使用单例模式。我有静态方法。现在我想调用静态方法内的非静态方法,但我无法调用它。请告诉我什么是解决scheme。 #import "ThemeManager.h" @implementation ThemeManager +(ThemeManager *)sharedInstance { NSLog(@"shared instance called"); static ThemeManager *sharedInstance = nil; if (sharedInstance == nil) { sharedInstance = [[ThemeManager alloc] init]; } [self getPref];//i get error at this line return sharedInstance; } -(void)getPref { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *themeName = [defaults objectForKey:@"theme"] ?: @"default"; NSLog(@"theme name is %@",themeName); […]

UIDatePicker最小/最大date

我创build了一个UIDatePicker,以便用户可以select他们的生日,并尝试设置最小和最大允许date。 但是,像下面所做的那样设置最小/最大date只会使date超出界限,但您仍然可以滚动到这些date。 如何防止dateselect器滚动到这些date,而不仅仅是将它们灰掉? NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setDay:1]; [comps setMonth:1]; [comps setYear:1914]; NSDate *minimumDate = [[NSCalendar currentCalendar] dateFromComponents:comps]; NSDateComponents *compsMax = [[NSDateComponents alloc] init]; [compsMax setDay:31]; [compsMax setMonth:12]; [compsMax setYear:2013]; NSDate *maximumDate = [[NSCalendar currentCalendar] dateFromComponents:compsMax]; birthdayPicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(220, 150, 500, 10)]; [birthdayPicker setDatePickerMode:UIDatePickerModeDate]; [birthdayPicker setMinimumDate:minimumDate]; [birthdayPicker setMaximumDate:maximumDate]; [birthdayPicker reloadInputViews]; […]

libpng错误:读取错误

我有一些PNG图像。 我打开它。 比我把它保存到文件。 而当我尝试打开保存的图像,我有这个问题。 libpng错误:读取 png_read_rows 错误 这是写代码: png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); png_infop info_ptr = png_create_info_struct(png_ptr); //created png struct setjmp(png_jmpbuf(png_ptr)) //signed png_init_io(png_ptr, file); png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); //set header unsigned char * buffer = (unsigned char*)malloc(4 *width * height); // created buffer unsigned char ** row_pointers = […]

GREE集成最终与错误

我在一个iOS应用程序(demo)中整合了GREE,经过一天的努力,代码已经足够好了,能够正确执行并产生了一些UI响应,但是可惜这并不值得,请检查: 我也有我的控制台中的东西; 2012-12-04 09:52:22.721 GreeHelloSample[1295:1bb03] GreeJSAbstractStateCommand:name must be overloaded in subclasses. 2012-12-04 09:52:22.724 GreeHelloSample[1295:1bb03] GreeJSAsyncCommand:name must be overloaded in subclasses. 2012-12-04 09:52:22.725 GreeHelloSample[1295:1bb03] GreeJSLoadAsynchronousCommand:name must be overloaded in subclasses. 2012-12-04 09:52:22.997 GreeHelloSample[1295:1bb03] [Gree][GreePlatform.m:381] Initialized Gree Platform SDK 3.4.0 (Build release/v3.4.0_public_189) 2012-12-04 09:52:24.589 GreeHelloSample[1295:1bb03] didLogoutUser 2012-12-04 09:52:25.003 GreeHelloSample[1295:1bb03] greePlatformWillShowModalView 但我累了,无法跟踪出了什么问题,现在呢? 所以,帮助我。 编辑1: 这里是我写的所有相关的代码: 。H #import <UIKit/UIKit.h> […]

我可以为CATransition设置最大的alpha值吗?

当视图淡入淡出时,是否可以调整CATransition的最大alpha(不透明度)? 我想要的东西看起来像一个模态赛格。 与默认模态CATransition相比, CATransition给出的转换非常“戏剧性”。 说我有两个意见。 答:我想从中过渡的观点。 B:我想转换到的视图。 我希望B从底部移动到A.为此,我使用kCATransitionMoveIntypes,子types为kCATransitionFromTop (这很奇怪,因为B从底部向上移动,而不是顶部)。 在默认模式segue,这工作正常,A只是灰色了一点。 随着CATransition ,A是完全黑色的过渡时期结束时,B已经超过了70%的移动。 码: UIStoryboard *loginBoard = [UIStoryboard storyboardWithName:@"Login" bundle:nil]; UIViewController *vc = [loginBoard instantiateInitialViewController]; UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window]; [keyWindow insertSubview:vc.view belowSubview:keyWindow.rootViewController.view]; CATransition *transition = [CATransition animation]; transition.duration = 0.5; transition.type = kCATransitionMoveIn; transition.subtype = kCATransitionFromTop; [keyWindow.layer addAnimation:transition forKey:kCATransition]; [keyWindow.rootViewController.view removeFromSuperview]; keyWindow.rootViewController = […]