小编use*_*346的帖子

TWOSweetComposeViewController在IOS6中已弃用

我的代码按预期工作只是因为我需要摆脱这个警告消息.在IOS6中不推荐使用TWTeetComposeViewController.是否在ios6中替换了这个内置视图控制器?

这是我的示例代码.

if ([TWTweetComposeViewController canSendTweet]) {
    // Initialize Tweet Compose View Controller
    TWTweetComposeViewController *vc = [[TWTweetComposeViewController alloc] init];
    // Settin The Initial Text
    [vc setInitialText:@"This tweet was sent using the new Twitter framework available in iOS 5."];
    // Adding an Image
    UIImage *image = [UIImage imageNamed:@"sample.jpg"];
    [vc addImage:image];
    // Adding a URL
    NSURL *url = [NSURL URLWithString:@"http://mobile.tutsplus.com"];
    [vc addURL:url];
    // Setting a Completing Handler
    [vc setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
        [self dismissModalViewControllerAnimated:YES];
    }];
    // Display Tweet Compose View Controller Modally
    [self presentViewController:vc …
Run Code Online (Sandbox Code Playgroud)

twitter objective-c ios ios6

37
推荐指数
2
解决办法
2万
查看次数

导航返回上一个视图控制器

我有一个UIView->UICollectionView->UICollectionViewCell.我试图以编程方式返回,但这些都不起作用.代码确实调用了.我正在使用StoryBoard.

- (void) goBack:(NSNotification *) notification {
      // [self.navigationController popViewControllerAnimated:YES];
     //  [self dismissViewControllerAnimated:YES completion:nil];
      [self.navigationController popToRootViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)

objective-c uinavigationcontroller ios

37
推荐指数
3
解决办法
7万
查看次数

XDebug无法连接到客户端

我正尝试在本地调试NetBeans Mac.

这是我的php.ini

[xdebug]
 xdebug.default_enable=1
 xdebug.remote_enable=1
 xdebug.remote_handler=dbgp
 xdebug.remote_host=localhost
 xdebug.remote_port=9000
 xdebug.remote_autostart=1
 xdebug.remote_log="/Applications/MAMP/logs/xdebug.log"
 xdebug.idekey="netbeans-xdebug"
 zend_extension="/Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
Run Code Online (Sandbox Code Playgroud)

这是我在xdebug.log中获得的

  I: Connecting to configured address/port: localhost:9000.
   E: Could not connect to client. :-(
Run Code Online (Sandbox Code Playgroud)

我尝试将端口更改为9001并关闭防火墙,但它没有帮助.

php netbeans xdebug

15
推荐指数
3
解决办法
1万
查看次数

亚马逊s3上传文件超时

我有一个800KB的JPG文件.我尝试上传到S3并继续获得超时错误.你能想出什么是错的吗?800KB对于上传而言相当小.

错误消息:未在超时期限内读取或写入与服务器的套接字连接.空闲连接将被关闭.

HTTP状态代码:400

AWS错误代码:RequestTimeout

Long contentLength = null;
System.out.println("Uploading a new object to S3 from a file\n");
try {
    byte[] contentBytes = IOUtils.toByteArray(is);
    contentLength = Long.valueOf(contentBytes.length);
} catch (IOException e) {
    System.err.printf("Failed while reading bytes from %s", e.getMessage());
}

ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(contentLength);        

s3.putObject(new PutObjectRequest(bucketName, key, is, metadata));
Run Code Online (Sandbox Code Playgroud)

java amazon-s3

12
推荐指数
1
解决办法
2万
查看次数

当焦点和键盘隐藏文本字段时滚动到文本字段

我有多个文本字段,当我专注于文本框时,它将自动向上滚动,键盘将隐藏文本框。

知道如何在单击时将文本字段滚动到焦点字段吗?

- (void)registerForKeyboardNotifications
{
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWasShown:)
                                                 name:UIKeyboardDidShowNotification object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillBeHidden:)
                                                 name:UIKeyboardWillHideNotification object:nil];

}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    activeField = textField;
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    activeField = nil;
}
// Called when the UIKeyboardWillHideNotification is sent
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{
    UIEdgeInsets contentInsets = UIEdgeInsetsZero;
    scrollView.contentInset = contentInsets;
    scrollView.scrollIndicatorInsets = contentInsets;
}
- (void)keyboardWasShown:(NSNotification*)aNotification
{
    NSDictionary* info = [aNotification userInfo];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;

    UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
    scrollView.contentInset = contentInsets;
    scrollView.scrollIndicatorInsets …
Run Code Online (Sandbox Code Playgroud)

keyboard objective-c uitextfield ios

4
推荐指数
1
解决办法
4486
查看次数

圆形浮动值为.1(十位)

可能重复:
如何将浮点值舍入到小数点后2位?

假设我的双数为3.46.如何将其舍入到3.50?我试过了

NSLog(@"res: %.f", round(3.46)); 
Run Code Online (Sandbox Code Playgroud)

但它返回3.

floating-point objective-c rounding ios

4
推荐指数
1
解决办法
2785
查看次数

UITextview始终显示垂直滚动条

我试图在代码的开头用uitextview显示垂直滚动条,但它没有这样做.

UITextView *txtView=[[UITextView alloc]initWithFrame:CGRectMake(10, 80,self.view.frame.size.width-20,self.view.frame.size.height/2)];    
[txtView setEditable:NO];
[txtView setSelectable:NO];
[txtView setText:self.secret];
[txtView setBackgroundColor:[UIColor clearColor]];
[txtView setTextColor:[UIColor whiteColor ]];
[txtView setFont:font];
txtView.showsVerticalScrollIndicator=YES;
[txtView flashScrollIndicators];
[self.view addSubview:txtView];
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uitextview ios

1
推荐指数
1
解决办法
2978
查看次数