当我使用NSASCIIStringEncoding为GET请求编码一些中文字符时.
NSLog(@"%@",searchText);
NSString *stringForSearch = [searchText stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSLog(@"%@",stringForSearch);
Run Code Online (Sandbox Code Playgroud)
2012-05-05 23:51:02.669 StarHopeFundingApprovalSystem [756:f803]中
2012-05-05 23:51:06.305 StarHopeFundingApprovalSystem [756:f803](null)
第一个日志是一个中文字符,但第二个日志总是(null),请帮我这个,谢谢你提前.
视图控制器:
@implementation PaiLifeViewController
@synthesize detail = _detail;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImage *i = [UIImage imageNamed:@"menu_patcode_normal"];
UIButton *c1 = [[UIButton alloc] init];
c1.tag = 11;
UIButton *c2 = [[UIButton alloc] init];
c2.tag = 12;
UIButton *c3 = [[UIButton alloc] init];
c3.tag = 13;
UIButton *c4 = [[UIButton alloc] init];
c4.tag = 21;
UIButton *c5 = [[UIButton alloc] init];
c5.tag = 22;
UIButton *c6 = [[UIButton alloc] …Run Code Online (Sandbox Code Playgroud) 我使用NSTimer进行自动幻灯片,我的代码是这样的:
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval: 5
target: self
selector: @selector(handleTimer)
userInfo: nil
repeats: YES];
- (void)handleTimer
{
int page = _bannerScrollView.contentOffset.x / 296;
if ( page + 1 < [array count] )
{
page++;
_pageControl.currentPage = page++;
}
else
{
page = 0;
_pageControl.currentPage = page;
}
[self changePage];
}
- (void)changePage
{
int page = _pageControl.currentPage;
[_bannerScrollView setContentOffset:CGPointMake(296 * page, 0)];
}
Run Code Online (Sandbox Code Playgroud)
我需要一些动画,因为它很酷.我怎样才能做到这一点?非常感谢你.

@interface ViewController ()<UITextViewDelegate>
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"www.google.com"];
NSDictionary *linkDic = @{ NSLinkAttributeName : [NSURL URLWithString:@"http://www.google.com"] };
[str setAttributes:linkDic range:[[str string] rangeOfString:@"www.google.com"]];
_textView.attributedText = str;
}
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
{
NSLog(@"=============%@",URL);
return YES;
}
Run Code Online (Sandbox Code Playgroud)
有什么不对?
我正在使用ASIHTTPRequest [request startAsynchronous]functon向我的webservice api发送请求以登录.如果请求正常,则返回json值.然后我发送另一个请求来获取用户的信息,但在这里我收到一个错误.
这是我的代码:
-(void)login
{
[usernameTextField resignFirstResponder];
[passwordTextField resignFirstResponder];
username = [usernameTextField text];
password = [passwordTextField text];
if ( ([username length] == 0 ) || ([password length] == 0 ))
{
...
}
else
{
NSString *URL = [NSString stringWithFormat:@"https://xxx.xxx.xx.xx/FMS/Pages/Service/FMService.svc/Login?user=%@&pass=%@",username,password];
NSURL *requestURL = [NSURL URLWithString:URL];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:requestURL];
[request setValidatesSecureCertificate:NO];
[request setDelegate:self];
[request startAsynchronous];
}
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSError *error = [request error];
if (!error)
{
NSString *responseString = [request responseString];
NSDictionary *responseDict …Run Code Online (Sandbox Code Playgroud) 我的视图控制器中只有一个UITableView,我的代码是:
@interface MyViewController ()<UITableViewDataSource,UITableViewDelegate>
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, [UIScreen mainScreen].bounds.size.height) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollsToTop = YES;
[self.view addSubview:self.tableView];
Run Code Online (Sandbox Code Playgroud)
它甚至没有运行:
- (BOOL) scrollViewShouldScrollToTop:(UIScrollView*) scrollView
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,我该如何解决这个问题?非常感谢你.
ios ×6
uiscrollview ×2
animation ×1
nsstring ×1
nsurl ×1
uibutton ×1
uitableview ×1
uitextview ×1
urlencode ×1