我创建一个自定义退格按钮,但我的问题是我的后退按钮工作很好,以便从单词中间删除字符,但只删除1个字符后(删除字母),回到行尾它意味着不留在哪里光标是,这是我的代码:
NSRange deleteRange = textPad.selectedRange;
if (deleteRange.length >0)
textPad.text = [textPad.text stringByReplacingCharactersInRange:deleteRange withString:@""];
else
if (deleteRange.location > 0)
textPad.text = [textPad.text stringByReplacingCharactersInRange:NSMakeRange(deleteRange.location-1,1)
withString:@""];
Run Code Online (Sandbox Code Playgroud) 我想知道如何为UILabel创建文本笔划?有什么办法吗?

谢谢 ,
#import <Foundation/Foundation.h>
@interface CustomLabel : UILabel {
}
@end
#import "CustomLabel.h"
@implementation CustomLabel
- (void)drawTextInRect:(CGRect)rect {
CGSize shadowOffset = self.shadowOffset;
UIColor *textColor = self.textColor;
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c, 22);
CGContextSetTextDrawingMode(c, kCGTextStroke);
self.textColor = [UIColor whiteColor];
[super drawTextInRect:rect];
CGContextSetTextDrawingMode(c, kCGTextFill);
self.textColor = textColor;
self.shadowOffset = CGSizeMake(0, 0);
[super drawTextInRect:rect];
self.shadowOffset = shadowOffset;
//works fine with no warning
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是我如何在不同的viewcontrollers上使用带有IBOutlet标签的子类.这样对吗 :
label = [[CustomLabel alloc] initWithFrame:CGRectMake(0, 0, 190, 190)];
Run Code Online (Sandbox Code Playgroud) 我想创建一个电影介绍的应用程序,就像gameloft游戏一样.因此,当应用程序已经发布时,电影播放正常,但在移动播放之前..我的FirstViewController xib文件首先显示然后电影开始播放!为什么?这是我的代码:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"movie" ofType:@"m4v"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *IntroMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
IntroMovie.movieControlMode = MPMovieControlModeHidden;
[IntroMovie play];
}
Run Code Online (Sandbox Code Playgroud) 我有几个IBOutlet并将它们与IBOutletCollection一起使用:
@interface IBOutletCollectionViewController : UIViewController {
IBOutletCollection (UILabel) NSArray *multipleLabels;
}
@property (nonatomic , retain) IBOutletCollection (UILabel) NSArray *multipleLabels;
@end
Run Code Online (Sandbox Code Playgroud)
但是当我想使用UILable属性时,编译器会给出以下错误:
请求成员'textColor'不是结构或联合
我认为这是因为NSArray!那有什么解决方案吗?
我正在使用Facebook Connect在我的应用程序上分享一些内容.所以我想通过2个按钮实现Facebook Connect API,"在Facebook上登录/分享" UIACtionSheet.
现在,我有一些问题:
假设我有两个UIActionSheet标题为"在Facebook上分享""登录"的按钮.
我想,当用户登录Facebook时,我的登录按钮标题将更改为"注销".我知道我应该使用这个功能:
- (void)session:(FBSession*)session didLogin:(FBUID)uid {
//a code that change my login button title to LogOut
}
Run Code Online (Sandbox Code Playgroud)
2-我已登录Facebook.当我要从我的应用程序中出去并再次打开应用程序时,我应该再次登录!我怎么能阻止这个?
3-最后,我想将一些文本从UIWebView分享到Facebook.我的webview插座名为"myWeb".我如何将Facebook Connect与UIWebView连接以共享它?
我应该用吗?
-(void)publishFeed:(id)target
Run Code Online (Sandbox Code Playgroud)
?
我想知道什么是iphone日历表?以及如何实现它.
alt text http://patrickmd.net/blog/wp-content/uploads/2008/10/iphone_calendar_sshot.png
我需要一些关于这些问题的信息:
它是否会改变日历数据?并创建例如波斯日历?如何将事件导入表中?
我创建了一个UISearchBar,我必须在inputAccessoryView中插入一个视图,但编译器给了我这个错误:
分配给只读属性
为什么会这样?:
@property(nonatomic,retain)IBOutlet UISearchBar *searchbar;
@property (retain, nonatomic) IBOutlet UIView *keyView;
self.searchbar.inputAccessoryView = keyView;
Run Code Online (Sandbox Code Playgroud) 我为我的应用程序制作了一个简单的照片幻灯片,问题是我的代码不再重复最后一张图像后的图像了!这是我的代码:
- (IBAction)start:(id)sender {
_button.hidden = YES;
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(photoCounter) userInfo:nil repeats:YES];
}
- (void)photoCounter {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.90];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
[self updatePhoto];
imageCount ++;
[UIView commitAnimations];
}
- (void)updatePhoto {
switch (imageCount) {
case 0:
_images.image = [UIImage imageNamed:@"wall1.jpg"];
break;
case 1:
_images.image = [UIImage imageNamed:@"wall2.jpg"];
break;
case 2:
_images.image = [UIImage imageNamed:@"wall3.jpg"];
break;
case 3:
_images.image = [UIImage imageNamed:@"wall4.jpg"];
break;
case 4:
_images.image = [UIImage imageNamed:@"wall5.jpg"];
break;
default:
break;
}
}
Run Code Online (Sandbox Code Playgroud)