小编kar*_*yan的帖子

iOS 11关于iPhone x安全区域的布局指南

我的应用程序已经在应用程序商店中,昨天我将我的Xcode版本更新为9并且除了iPhone x以外工作正常.用户界面崩溃了.

1.我已经创建了两个UIView(两者都是固定高度),名为Header和Tab bar,我已经隐藏了我的NavigationBar整个应用程序.

2.为UIViewController添加了扩展,用于创建HeaderTab栏

func addHeaderTab(currentViewController:UIViewController,content:String, isMenu:Bool){
        let noView = TopHeaderView()
        noView.tag = 12345
        noView.isMenu = isMenu
        noView.translatesAutoresizingMaskIntoConstraints = false
        currentViewController.view .addSubview(noView)
        if isMenu{
            noView.menuBtn .setImage(UIImage(named: "Small"), for: .normal)
            noView.logoImg.isHidden = false

        }else{
            noView.menuBtn .setImage(UIImage(named: "arrow_small"), for: .normal)
            noView.logoImg.isHidden = true
        }
        noView.titleLbl.text = content
        noView.delegate = (currentViewController as! menuOpen)

        NSLayoutConstraint(item: noView, attribute: .leading, relatedBy: .equal, toItem: currentViewController.view, attribute: .leading, multiplier: 1.0, constant: 0.0).isActive = true

        NSLayoutConstraint(item: noView, …
Run Code Online (Sandbox Code Playgroud)

ios autolayout swift4 xcode9 iphone-x

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

JSON写入中的类型无效(NSConcreteData)?

我正在使用AFNetworking发布带有一些数据的音频.我得到以下异常.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSConcreteData)'
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码..

dict=@{@"access_token":[defaults valueForKey:@"TOKEN"],@"email":email,@"prayer":passData};

if ([NSJSONSerialization isValidJSONObject:dict]) {
        NSLog(@"Proper JSON Object");

    }
    NSError *error;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];

    NSURL *URL = [NSURL URLWithString:url];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL
                                                           cachePolicy:NSURLRequestReloadIgnoringCacheData  timeoutInterval:10];

    [request setHTTPMethod:@"POST"];
    [request setValue: @"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:jsonData];
 AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    op.responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments];
    [op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {}
Run Code Online (Sandbox Code Playgroud)

我需要以这种格式发布值

{
    "access_token" = 2cf0d8a66654fa4f;
    email = ""; …
Run Code Online (Sandbox Code Playgroud)

json ios afnetworking

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

从下一个minitue计算当前时间,然后NSTimer不应该工作

嗨,我是iOS的新手.现在我对这个概念感到困惑.我的概念就是当我点击按钮时我想获得当前时间(HH:MM:SS).在按钮上我做了一些重复的任务通过使用NSTimer.once我得到NSTimer sholud无效后的当前时间(nstimer呼叫每个(0.05f)).在这里我需要计算紧急时间与下一个minitue.thanks提前.不要误以为我我是愚蠢的英文.这是我现在还在的代码..

- (void) scanButtonTouchUpInside {


    if (check) {
        position=CGPointMake(14.0f, 7.0f);
        position1=CGPointMake(7.0f, 14.0f);
        check=NO;

       timer= [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];



    }
  else
  {
      //animation stop code here.................
      if ([timer isValid]) {
          [timer invalidate];
      }
      check=YES;
      NSLog(@"stopppppppp.....................");
//      overlayGraphicView.frame = CGRectMake(30, 100, 32, 32);
//      overlayGraphicView1.frame = CGRectMake(30, 152, 32, 32);
  }


}

-(void)onTimer
{


    overlayGraphicView.center = CGPointMake(overlayGraphicView.center.x+position.x,overlayGraphicView.center.y+position.y);

    if(overlayGraphicView.center.x > 320 || overlayGraphicView.center.x < 0)
        position.x = -position.x;
    if(overlayGraphicView.center.y > 480 || overlayGraphicView.center.y < 0)
        position.y = -position.y; …
Run Code Online (Sandbox Code Playgroud)

iphone nstimer ios

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

错误 ITMS-90513:缺少 Info.plist 键。您的应用程序的 Info.plist 必须包含“TVTopShelfImage.TVTopShelfPrimaryImageWide”键

我们正在尝试将 TV OS 版本上传到应用商店,但总是失败..请找到错误截图

错误图像

我们尝试了很多可能性,但没有任何帮助,我们使用的是 Xcode 9 版本,我们还添加了 1920X720 图像。

重新启动系统也没有帮助。

assets ios apple-tv tvos11

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

如何在iOS 8中创建自定义委托?

我已经创建了委托方法并使用Xcode较低版本但不能在Xcode 6.1中工作.

它显示错误无法查找协议声明NSObject

尝试代码: .h文件

@class ReportCell;
@protocol keyboardDelegate <NSObject>

@optional
- (BOOL)leaveKeyboard:(ReportCell *)cell ;

@end


#import <UIKit/UIKit.h>

@interface ReportCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UIImageView *imgReport;
@property (strong, nonatomic) IBOutlet UITextField *txtReport;
@property (strong, nonatomic) IBOutlet UIView *viewReport;
@property (nonatomic, assign) id <keyboardDelegate> delegate;

@end
Run Code Online (Sandbox Code Playgroud)

.m文件

 #import "ReportCell.h"

    @implementation ReportCell

    - (void)awakeFromNib
    {
        // Initialization code
    }

    - (void)setSelected:(BOOL)selected animated:(BOOL)animated
    {
        [super setSelected:selected animated:animated];

        // Configure the view for the selected state
    }
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios

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

显示一天,一小时前不能正常工作?

我已经完成了这段代码

+ (NSString *)relativeDateStringForDate:(NSString *)date
{
    NSString *temp;

    NSString* format = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
    // Set up an NSDateFormatter for UTC time zone
    NSDateFormatter* formatterUtc = [[NSDateFormatter alloc] init];
    [formatterUtc setDateFormat:format];
    [formatterUtc setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
    // Cast the input string to NSDate
    NSDate* utcDate = [formatterUtc dateFromString:date];
    // Set up an NSDateFormatter for the device's local time zone
    NSDateFormatter* formatterLocal = [[NSDateFormatter alloc] init];
    [formatterLocal setDateFormat:format];
    [formatterLocal setTimeZone:[NSTimeZone localTimeZone]];
    // Create local NSDate with time zone difference
    NSDate* localDate = [formatterUtc dateFromString:[formatterLocal stringFromDate:utcDate]]; …
Run Code Online (Sandbox Code Playgroud)

objective-c ios relative-time-span

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

CAShapeLayer 到 UILabel 隐藏文本

我正在尝试添加一个CAShapeLayerUILabel.
问题是:这样做后文本消失了:

let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.fillColor = UIColor.yellow.cgColor
item.layer.addSublayer(shapeLayer)
Run Code Online (Sandbox Code Playgroud)

有没有其他方法可以做到这一点?

cashapelayer ios swift

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