小编Ale*_*dro的帖子

NSTimer内存管理

当我执行此代码时:

[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(showButtons) userInfo:nil repeats:NO];
Run Code Online (Sandbox Code Playgroud)

我需要将它取消或释放它,不管内存管理是什么?

我正在使用ARC

nstimer ios strong-references

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

来自app delegate的UIStoryboard加载

我试图以这种方式从app delegate .m加载UIStoryboard:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    
    UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
    UIViewController *vc =[storybord instantiateInitialViewController];
    [self.window addSubview:vc.view];

    return YES;
}
Run Code Online (Sandbox Code Playgroud)

这段代码有什么问题?任何的想法?

objective-c ios uistoryboard

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

来自iOS的PayPal错误580001 HTTP请求

在iOS中实施自适应支付存在一些困难,遗憾的是,PayPal网站或响应的文档很少.这是代码:

- (void)makePaymentSandbox{

    NSError *error;

    //NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
    //NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];

    NSURL *url = [NSURL URLWithString:@"https://svcs.sandbox.paypal.com/AdaptivePayments/Pay"];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
                                                           cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                       timeoutInterval:30.0];

    //setting
    [request setHTTPMethod:@"POST"];

    //headers
    [request addValue:@"alex-facilitator_api1.fastwebnet.it" forHTTPHeaderField:@"X-PAYPAL-SECURITY-USERID"];
    [request addValue:@"FW79EZXASW69NE8X" forHTTPHeaderField:@"X-PAYPAL-SECURITY-PASSWORD"];
    [request addValue:@"ABZua9nnv9oieyN4MwVt15YdgetaJHcyzqOHjkLbuM-bGRoI7WRS" forHTTPHeaderField:@"X-PAYPAL-SECURITY-SIGNATURE"];
    //NV
    [request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-REQUEST-DATA-FORMAT"];
    [request addValue:@"JSON" forHTTPHeaderField:@"X-PAYPAL-RESPONSE-DATA-FORMAT"];

    [request addValue:@"APP-80W288712P519543T" forHTTPHeaderField:@"X-PAYPAL-APPLICATION-ID"];

    [request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request addValue:@"en_US" forHTTPHeaderField:@"Accept-Language"];


    //data

    /*NSString *userUpdate =[NSString stringWithFormat:@"clientDetails.applicationId=%@&actionType=%@",@"APP-80W284485P519543T", @"PAY",nil];
    NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:data1];
    [request setValue: [NSString stringWithFormat:@"%lu", (unsigned long)[data1 length]] forHTTPHeaderField:@"Content-Length"];*/


    NSDictionary …
Run Code Online (Sandbox Code Playgroud)

paypal ios

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

UIStoryboard名称和包

我有这行代码:

[UIStoryboard storyboardWithName:(NSString *) bundle (NSBundle *)];
Run Code Online (Sandbox Code Playgroud)

和故事板文件.我在哪里插入控制器的名称,以及在哪里找到捆绑包?

这是一个愚蠢的问题,但我无法弄清楚

xcode ios

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

iOS 8 TestFlight无法安装应用

正如标题所说,我正在尝试预发布ios8应用程序.该应用程序已从存档成功上载,并在预发布下显示.我按下提交测试版并添加内部测试用户.在testflight中,应用程序出现,但是当我按下安装时它会说:

"无法安装应用,testflight目前无法使用.请稍后重试".

这毫无意义.我尝试重新创建开发人员配置文件,我在不同设备上尝试使用不同的帐户...总是一样的.有任何想法吗?

ios

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

从iOS库导入时显着的图像质量损失

我使用iPad照片库(相机胶卷)导入一些图像,并将它们放在我使用alloc方法创建的UIImageView中.但是当显示图像时,图像质量会有很大的损失.例如,在图书馆中有一个图像,河流非常清晰,逐像素,但是当我导入它时,它会丢失至少一半的像素.这是导入图像的代码:

- (IBAction) useCameraRoll: (id)sender
{
    @autoreleasepool {

if ([self.popoverController isPopoverVisible]) {
    [self.popoverController dismissPopoverAnimated:YES];

} else{

    }{
    if ([UIImagePickerController isSourceTypeAvailable:
         UIImagePickerControllerSourceTypeSavedPhotosAlbum])
    {
        @autoreleasepool {

        UIImagePickerController *imagePicker =
        [[UIImagePickerController alloc] init];

        imagePicker.delegate = self;
        imagePicker.sourceType =
        UIImagePickerControllerSourceTypePhotoLibrary;
        imagePicker.mediaTypes = [NSArray arrayWithObjects:
                                  (NSString *) kUTTypeImage,
                                  nil];

        imagePicker.allowsEditing = YES;

        self.popoverController = [[UIPopoverController alloc]
                                  initWithContentViewController:imagePicker];
        }
        popoverController.delegate = self;

        [self.popoverController 
         presentPopoverFromBarButtonItem:sender
         permittedArrowDirections:UIPopoverArrowDirectionUp
         animated:YES];


        newMedia = NO;


    }}
}
}

-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [self.popoverController dismissPopoverAnimated:true];
@autoreleasepool {

NSString *mediaType = [info
                       objectForKey:UIImagePickerControllerMediaType]; …
Run Code Online (Sandbox Code Playgroud)

xcode ios

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

更改引脚颜色MKMapView

我以这种方式向地图添加注释:

MyAnnotation *annotationPoint2 = [[MyAnnotation alloc] init];
annotationPoint2.coordinate = anyLocation;
annotationPoint2.title = [NSString stringWithFormat:@"%@", obj];
annotationPoint2.subtitle = @"";  //or set to nil
annotationPoint2.keyValue = [NSString stringWithFormat:@"%@", key];
[mapPins addAnnotation:annotationPoint2];
Run Code Online (Sandbox Code Playgroud)

针脚都是红色的,我希望它们都是绿色的.我怎样才能改变颜色?我尝试了以下内容,但仍然给出了红色标记:

annotationPoint2.pinColor = MKPinAnnotationColorGreen;
Run Code Online (Sandbox Code Playgroud)

mkpinannotationview mkmapview ios

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

淡出任何接近UIScollView边缘的内容

正如标题所说,我试图给一些UIImageViews一个淡出效果,因为它们越来越接近我的UIScrollView的四个边缘中的任何一个.由于用户可以拖动UIImages,如果他将它们拖向边缘,它们会开始淡出,而不是像UIScrollView的边框那样给出剪切效果.我试过这个教程:

http://www.cocoanetics.com/2011/08/adding-fading-gradients-to-uitableview/

建议在另一个堆栈溢出问题,但它只能应用于UITableViews.我希望图像开始褪色,因为它距离边界一厘米.

uiscrollview ios quartz-core

9
推荐指数
2
解决办法
8770
查看次数

接受邀请多重连接

我希望我没有通过发布这个问题来违反NDA.

我正在使用新的多路连接,使用蓝牙将一些文件发送到附近的设备.我已设法发送邀请,但我似乎没有得到如何显示UIAlertView,用户可以接受或拒绝邀请.现在,当用户发送时,文件会自动保存,并且没有接受/拒绝警​​报.

代码是:

- (void) advertiser:(MCNearbyServiceAdvertiser *)advertiser
didReceiveInvitationFromPeer:(MCPeerID *)peerID
               withContext:(NSData *)context
         invitationHandler:(void(^)(BOOL accept,
                                    MCSession *session))invitationHandler{
... save the data context
Run Code Online (Sandbox Code Playgroud)

但有警报:

- (void) advertiser:(MCNearbyServiceAdvertiser *)advertiser
didReceiveInvitationFromPeer:(MCPeerID *)peerID
                withContext:(NSData *)context
         invitationHandler:(void(^)(BOOL accept,
                                    MCSession *session))invitationHandler{


DevicePeer = [MCPeerID alloc];
DevicePeer = peerID;
ArrayInvitationHandler = [NSArray arrayWithObject:[invitationHandler copy]];

// ask the user
UIAlertView *alertView = [[UIAlertView alloc]
                          initWithTitle:@""
                          message:@""
                          delegate:self
                          cancelButtonTitle:@"NO"
                          otherButtonTitles:@"YES", nil];
[alertView show];
 alertView.tag = 2;
}
Run Code Online (Sandbox Code Playgroud)

和警报视图方法:

 - (void) alertView:(UIAlertView *)alertView
 clickedButtonAtIndex:(NSInteger)buttonIndex
{  
    // retrieve the invitationHandler
    // get user …
Run Code Online (Sandbox Code Playgroud)

ios multipeer-connectivity

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

将CAShapeLayer蒙版应用于UIView

我正在使用此代码将图层应用于UIview:

mask = [[CAShapeLayer alloc] init];
mask.frame = baseView.layer.bounds;
CGRect biggerRect = CGRectMake(mask.frame.origin.x, mask.frame.origin.y, mask.frame.size.width, mask.frame.size.height);
CGRect smallerRect = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f);

UIBezierPath *maskPath = [UIBezierPath bezierPath];
[maskPath moveToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMinY(biggerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMaxY(biggerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(biggerRect), CGRectGetMaxY(biggerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(biggerRect), CGRectGetMinY(biggerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMinY(biggerRect))];

[maskPath moveToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMinY(smallerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMaxY(smallerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(smallerRect), CGRectGetMaxY(smallerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(smallerRect), CGRectGetMinY(smallerRect))];
[maskPath addLineToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMinY(smallerRect))];

mask.path = maskPath.CGPath;
[mask setFillRule:kCAFillRuleEvenOdd];
mask.fillColor = [[UIColor blackColor] CGColor];
baseView.layer.mask = mask;
Run Code Online (Sandbox Code Playgroud)

由于我要剪切的矩形发生了变化,我很想知道是否有一种快速方法可以更改蒙版的大小,而不是仅仅从UIview中删除它并使用不同的尺寸重新应用它:

例如

[mask removeFromSuperlayer];
Run Code Online (Sandbox Code Playgroud)

和...

mask = [[CAShapeLayer alloc] …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch uiview cashapelayer ios

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