小编DaS*_*lva的帖子

iOS7和Apple Watch

我有一个最低iOS目标iOS7的应用程序.

我正在考虑为苹果手表添加一些额外的功能.Theres是将iOS7维持为最低目标的任何选项,如果应用程序在iOS 8上运行,仍然可以添加对Apple Watch的支持吗?类似于iOS8的扩展/小部件.

提前致谢

ios ios7 apple-watch watchkit

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

AFHTTPSessionManager将主体添加到POST

我也需要向我的服务器发帖子请求.

使用AFHTTPRequestOperation非常简单,只需使用:

[request setHTTPBody: [requestBody dataUsingEncoding:NSUTF8StringEncoding]];
Run Code Online (Sandbox Code Playgroud)

但是,我找不到任何使用AFHTTPSessionManager使用相同方法的示例.

使用方法:

[self POST:@"extraLink" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {

} success:^(NSURLSessionDataTask *task, id responseObject) {

} failure:^(NSURLSessionDataTask *task, NSError *error) {

}];
Run Code Online (Sandbox Code Playgroud)

我如何将主体添加到"AFMultipartFormData"?

谢谢你的推荐

ios ios7 afnetworking-2

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

当互联网不可用时关闭应用程序

我想在互联网连接不可用时关闭我的应用程序.

我检查一下,但是如何创建警报,然后关闭我的应用程序?

objective-c ios

8
推荐指数
4
解决办法
3109
查看次数

使用textfield重用单元格

我有一个内置UITextfield的自定义单元格.该细胞对不同类型的模型具有不同的行为.例如,我可以使用模型来呈现数字或其他来呈现日期.

如果是数字,它只能引入数字,如果是用户开始在文本字段上键入的日期,则显示选择日期的uipicker.

在方法cellForRow中,我将textfield的委托设置为模型,它将实现单元格的每个行为.

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    //Get Element
    SuperElement * elem = [self.arrayFields objectAtIndex:indexPath.row];
    //Get Cell of the element
    SuperCell *cell = (SuperCell*)[elem returnCellForCollectionView:collectionView andIndexPath:indexPath];

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

DateElement

-(UICollectionViewCell*)returnCelForCollectionView:(UICollectionView*)collectionView andIndexPath:(NSIndexPath*)indexPath{

    SuperCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[SuperCell reuseIdentifier]
                                                                    forIndexPath:indexPath];
    cell.textField.text = self.value;
    cell.textField.delegate =self;

return cell; }

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    //code to show picker
}
Run Code Online (Sandbox Code Playgroud)

NumberElement

-(UICollectionViewCell*)returnCelForCollectionView:(UICollectionView*)collectionView andIndexPath:(NSIndexPath*)indexPath{

        SuperCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[SuperCell reuseIdentifier]
                                                                        forIndexPath:indexPath];
        cell.textField.text = self.value;
        cell.textField.delegate =self;

    return cell;
}
  - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string
{ …
Run Code Online (Sandbox Code Playgroud)

uitableview uitextfield ios uicollectionviewcell

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

Apple Watch和openParentApplication在后台

我正在实施一个苹果手表.在我的Watchkit扩展中,我使用该方法与"主应用程序"进行通信.

    [WKInterfaceController openParentApplication:applicationData reply:^(NSDictionary *replyInfo, NSError *error) {}];
Run Code Online (Sandbox Code Playgroud)

根据Apple 文档,该应用程序可以在后台处理请求.

When you call the openParentApplication:reply: method, iOS launches or 
wakes up the parent app in the background and calls the
application:handleWatchKitExtensionRequest:reply:method of its app delegate.
Run Code Online (Sandbox Code Playgroud)

但是我的应用程序总是变为活动状态,即使我在方法中没有代码,handleWatchKitExtensionRequest

任何提示,如果可能的话?

提前致谢

ios apple-watch watchkit

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

RxSwift从Observable序列中的一个项获取值

我正在尝试逐渐将我的应用程序转换为RxSwift/MVVM.但我认为我做错了一些事情.

在这个例子中,我有一个包含这些特定信息的静态表.

    let itens = Observable.just([
        MenuItem(name: GlobalStrings.menuItemHome,      nameClass: "GPMainVC"),
        MenuItem(name: GlobalStrings.menuItemProfile,   nameClass: "GPMainVC"),
        MenuItem(name: GlobalStrings.menuItemLevels,    nameClass: "GPLevelsVC"),
    ])
Run Code Online (Sandbox Code Playgroud)

当用户选择一个单元格时,我需要知道模型(MenuItem)和索引,但我在这方面遇到了麻烦

 tableView.rx
        .itemSelected
        .map { [weak self] indexPath in
            return (indexPath, self?.modelView.itens.elementAt(indexPath.row))
        }
        .subscribe(onNext: { [weak self] indexPath, model in

            self?.tableView.reloadData()

            //can´t get MenuItem because model its a observable
            //self?.didSelect((indexPath as NSIndexPath).row, name.nameClass)

        })
        .addDisposableTo(disposeBag)
Run Code Online (Sandbox Code Playgroud)

提前致谢

ios swift rx-swift

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

警告Pods中缺少文件

我需要删除添加了可可豆荚的项目库.

为此,从pod的文件中取名,然后运行命令pod update.

该库已被删除,但xcode向我显示有关丢失文件的警告.

在此输入图像描述

我怎么能删除这个?

xcode ios cocoapods

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

使用AFNetworking在异步模式下调整UIImage的大小

我在我的应用程序中使用AFNetwork从我的Web服务中获取一些数据.在这些数据中,有一些随机大小的图像,我需要添加一些UIImageView.

我的问题是在异步模式下以正确的UIImageView 规模调整图像.

知道怎么做吗?

编辑

我正在使用Afnetwoking项目的常规方法:

 [self setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"img_my_nophoto"]];
Run Code Online (Sandbox Code Playgroud)

这个方法里面的逻辑是:

- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 
          placeholderImage:(UIImage *)placeholderImage 
                   success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
                   failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
{
    [self cancelImageRequestOperation];

UIImage *cachedImage = [[[self class] af_sharedImageCache] cachedImageForRequest:urlRequest];
if (cachedImage) {
    self.image = cachedImage;
    self.af_imageRequestOperation = nil;

    if (success) {
        success(nil, nil, cachedImage);
    }
} else {
    self.image = placeholderImage;

    AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
    [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        if ([[urlRequest …
Run Code Online (Sandbox Code Playgroud)

uiimageview uiimage ios ios5 afnetworking

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

TableView有2个列的行,iphone/ipad

谁能告诉我如何在Iphone SDK中用colums创建一个包含两个单元格的tableview?

订购方式如下:

  _____________
  |  1  |   2  |
  |_____|______|
  |  3  |   4  |
  |_____|______|
Run Code Online (Sandbox Code Playgroud)

最好的祝福

iphone uitableview ios4 ios

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

使用iOS Facebook-SDK 3.1获取电子邮件和个人资料的图像

最近我开始冒险将我的应用程序集成到facebook-sdk.

我有一个提供登录Facebook的应用程序.因此,在与facebook建立会话之后,这个想法是从用户那里获取一些数据并在我的服务器上用一些数据创建一个新数据,

  • 名称
  • 图片网址
  • 电子邮件
  • facebookID

因此,我使用的是最新版本的facebook sdk-3.1.我创建了一个具有用户权限的会话来获取电子邮件.

    NSArray *permissions = [[NSArray alloc] initWithObjects:
                        @"user_location",
                        @"email",
                        nil];

[FBSession openActiveSessionWithReadPermissions:permissions
                                   allowLoginUI:YES
                              completionHandler:
 ^(FBSession *session,
   FBSessionState state, NSError *error) {
     [self sessionStateChanged:session state:state error:error];
 }];
Run Code Online (Sandbox Code Playgroud)

会话成功创建,之后我开始创建用户.

 if (FBSession.activeSession.isOpen) {
        [[FBRequest requestForMe] startWithCompletionHandler:
         ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
             if (!error) {

                 self.userData.firstNameUser=user.name;
                 self.userData.lastNameUser=user.last_name;
                 self.userData.mainLocation=user.location.name;
                 self.userData.urlImageUser=user.link;
             }
         }];   
    }
Run Code Online (Sandbox Code Playgroud)

那么,如何将使用最后一个SDK的用户的其他数据,电子邮件图像的配置文件发送到我的服务器?

谢谢

iphone facebook facebook-graph-api ios ios6

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

在UITableView中获取Section的标题

我在TableView中设置了所有标题的部分.

稍后,我需要在任何部分的tableview中获取标题的值,

我怎么能直接向UITableView询问这些值?

没有代表协议:

    [self tableView:tableView titleForHeaderInSection:i]
Run Code Online (Sandbox Code Playgroud)

因为此方法会覆盖我自己的类的协议.

- (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
 {
     /* If datasource methdod is implemented, get´s the name of sections*/
     SEL nameForSection = @selector(nameForSection:);
    if ( (self.dataSource) && [self.dataSource respondsToSelector:nameForSection] )
    {
       NSString *titleSection = [self.dataSource nameForSection:section];
       return titleSection;
   }

return nil;
Run Code Online (Sandbox Code Playgroud)

}

谢谢提前......

iphone uitableview ipad ios

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

将Unsigned Long转换为ascii中的字符串

我需要将无符号长整数转换为ascii中基数"b"中的字符串.

我收到longbase(0 <b <16),我需要在缓冲区中设置它.知道如何做到这一点,没有itoa()?

Cumps

c c# c++

-6
推荐指数
1
解决办法
986
查看次数