Tag: objective c

UIPageViewController页面控制背景颜色

我在我的应用程序中使用UIPageViewController,它工作正常。 但是,它自动添加的页面控件具有隐藏当前视图控制器底部材质的黑色背景(请参阅下图)。 是否有可能调用UIPageViewController的页面控件并更改它的颜色? 我希望页面控制显示在视图控制器(例如,path应用程序的演练),如设置颜色而不是黑色清除。

点击手势识别器 – 哪个对象被点击?

我是手势识别器的新手,所以也许这个问题听起来很愚蠢:我将轻拍手势识别器分配给一堆UIViews。 在这个方法中,有可能找出哪个是被点击的,或者我需要使用屏幕上的点来找出它? for (NSUInteger i=0; i<42; i++) { float xMultiplier=(i)%6; float yMultiplier= (i)/6; float xPos=xMultiplier*imageWidth; float yPos=1+UA_TOP_WHITE+UA_TOP_BAR_HEIGHT+yMultiplier*imageHeight; UIView *greyRect=[[UIView alloc]initWithFrame:CGRectMake(xPos, yPos, imageWidth, imageHeight)]; [greyRect setBackgroundColor:UA_NAV_CTRL_COLOR]; greyRect.layer.borderColor=[UA_NAV_BAR_COLOR CGColor]; greyRect.layer.borderWidth=1.0f; greyRect.userInteractionEnabled=YES; [greyGridArray addObject:greyRect]; [self.view addSubview:greyRect]; NSLog(@"greyGrid: %i: %@", i, greyRect); //make them touchable UITapGestureRecognizer *letterTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(highlightLetter)]; letterTapRecognizer.numberOfTapsRequired = 1; [greyRect addGestureRecognizer:letterTapRecognizer]; }

UILabel:你如何设置字体大小?

你如何设置UILabel的字体大小? 我的代码: UILabel *myView = [[UILabel alloc] initWithFrame:RectFrame]; [myView setBackgroundColor:[UIColor blueColor]]; [myView setText:[NSString stringWithFormat:@" A"]]; [myView setFont:[12] ]; <— Error [self.view addSubview:myView];

如何使用arc4random()select值的范围

使用arc4random()时可以设置一个数字范围吗? 例如只有50-100。

删除导航栏的底部边框iOS7

有没有办法来删除iOS7自动显示在导航栏下的底部边框?

UITableViewCell突出显示标签的背景

我有UITableViewCell上的UIlabel,我已经编程创build(即不是一个笔尖或子类)。 当单元格突出显示(变为蓝色)时,会使UILabels的所有背景颜色变清晰。 我有2 UILabels,我不希望这是事实。 目前,我在UILabel后面使用UIImageView,使其看起来像背景颜色不会改变。 但是,这似乎是一个低效的方法来做到这一点。 当UITableViewCell突出显示时,如何停止某些UILabel的背景颜色变化?

运行程序时保持iphone的活跃

如何设置iPhone设备保持活动(不locking),而我的应用程序正在运行? 任何想法

UIPanGestureRecognizer在MKMapView?

我想添加一些逻辑,当用户移动地图视图,即他做一个平底锅。 但是,当我添加手势识别器,我想logging触摸,没有任何反应。 当我在另一个视图控制器尝试它,并将识别器添加到控制器的视图,那么它工作正常。 这里是我的代码(地图视图是应用程序委托的属性,因为即使它不可见,我也需要做一些其他的事情): – (void)viewDidLoad { … UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(showPan)]; [appDelegate.mapView addGestureRecognizer:panGesture]; [panGesture release]; } – (void)showPan { NSLog(@"pan!"); } 我使用最新的iOS 4.2.1 感谢您的任何build议。

从Facebook iOS 7获取用户名和个人资料照片

我已经阅读了很多关于从Facebook获取信息的教程,但到目前为止我失败了。 我只想从Facebook获取用户名和个人资料照片。 – (IBAction)login:(id)sender { [FBSession openActiveSessionWithReadPermissions:@[@"email",@"user_location",@"user_birthday",@"user_hometown"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { switch (state) { case FBSessionStateOpen: [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) { if (error) { NSLog(@"error:%@",error); } else { // retrive user's details at here as shown below NSLog(@"FB user first name:%@",user.first_name); NSLog(@"FB user last name:%@",user.last_name); NSLog(@"FB user […]

Objective-C与块的延迟行为

我知道在Objective-C中有几种延迟操作的方法,例如: performSelector:withObject:afterDelay: 或使用NSTimer 。 但是有一个叫块的东西,你可以这样做: [UIView animateWithDuration:1.50 delay:0 options:(UIViewAnimationOptionCurveEaseOut|UIViewAnimationOptionBeginFromCurrentState) animations:^{ }completion:^(BOOL finished){ }]; 不幸的是,这种方法只适用于animation的东西。 我怎样才能创build一个块的延迟在一个方法,所以我不必使用所有这些@select器,而不需要创build一个新的单独的方法 ? 谢谢!