小编iPh*_*e 7的帖子

UICollectionView椭圆形自定义单元格

如何UICollectionView使用自定义单元格生成椭圆形单元格.下面是我想要实现的图像.

在此输入图像描述

不知道如何实现这一点,通过几个链接,但没有得到.请指导.谢谢

更新:我尝试的是

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {


    return CGSize(width: collectionView.frame.size.width/3.0 - 8, height: collectionView.frame.size.width/2.5[![enter image description here][2]][2] )
}
Run Code Online (Sandbox Code Playgroud)

对于这种设计,但它不能按要求工作,它就变成了 在此输入图像描述

iphone ios uicollectionview swift

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

如何将情节提要中的插座连接到UITableViewCell类Xcode 11

How can we connect outlet with the table view custom cell class in storyboard? As in earlier Xcodes, there is a button to open two windows in storyboard screen but in new Xcode that button is missing. Please guide how to achieve that functionality.

storyboard uitableview ios xcode11

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

恢复自动续订订阅"transaction.originalTransaction.transactionIdentifier"为零

在购买交易后尝试恢复应用程序中的自动续订,它正在提供零

 "transaction.originalTransaction.transactionIdentifier"
Run Code Online (Sandbox Code Playgroud)

为什么我在成功购买订阅后无法恢复.请指导.

iphone in-app-purchase ios

5
推荐指数
0
解决办法
162
查看次数

使用Objective-C中的SCRecorder以改进的播放速度保存视频

使用SCRecorder希望在录制后保存视频,用户选择不同的播放速度ex:2x,3x.使用AVPlayer,可以使用以下代码实现:

//create mutable composition
AVMutableComposition *mixComposition = [AVMutableComposition composition];

AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
                                                                               preferredTrackID:kCMPersistentTrackID_Invalid];
NSError *videoInsertError = nil;
BOOL videoInsertResult = [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration)
                                                        ofTrack:[[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
                                                         atTime:kCMTimeZero
                                                          error:&videoInsertError];
if (!videoInsertResult || nil != videoInsertError) {
    //handle error
    return;
}

//slow down whole video by 2.0
double videoScaleFactor = 2.0;
CMTime videoDuration = asset.duration;

[compositionVideoTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero, videoDuration)
                           toDuration:CMTimeMake(videoDuration.value*videoScaleFactor, videoDuration.timescale)];

//export
AVAssetExportSession* assetExport = [[AVAssetExportSession alloc] initWithAsset:mixComposition
                                                                  //   presetName:AVAssetExportPresetLowQuality];
Run Code Online (Sandbox Code Playgroud)

但是,没有得到如何使用SCRecorder库实现相同的功能.请指导.提前致谢.

iphone objective-c playback video-recording ios

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

模块“Alamofire”没有名为“SessionManager”的成员

为什么我收到这个错误,我没有。我已经在使用Alamofire 5时将Alamofire更改为AF。请指导有什么问题以及需要更改的内容。下面是我遇到错误的代码:

 private func callAlamoFireFormalData(makeThisFunction : @escaping (AFDataResponse<Any>)->Void )
{
    AF.request(url, method: httpMethod, parameters: paramters, encoding: encoding, headers: HTTPHeaders(self.headers ?? [:]))
        //.validate(statusCode: 200..<300)
        .responseJSON { response in
            
            //print("\(response.response?.statusCode)")
            guard response.response?.statusCode != 401
                else{
                    
                    Alamofire.SessionManager.default.session.getAllTasks { tasks in
                        tasks.forEach { $0.cancel() }
                    }
                    Helper.setApiToken(token: "")
                    Helper.removeUserInfo()
                    if var topController = UIApplication.shared.keyWindow?.rootViewController {
                        if let presentedViewController = topController.presentedViewController
                        {
                            topController = presentedViewController
                            topController.present(UIStoryboard.init(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "InitialNAV"), animated: true, completion: nil)
                        }
                        
                        // topController should now be your topmost view controller
                    } …
Run Code Online (Sandbox Code Playgroud)

iphone ios swift alamofire xcode11

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

如何在UITextView中粘贴长文本

如何在UITexView中粘贴长文本,因为我有静态文本数据.如果我尝试直接粘贴到textView.text,它会显示错误.如何管理.请指导.提前致谢.

txtView.txt = @"About us

myventr.co is a web-based tool for event creation, event searching and online ticket      selling whilst also serving as a social media network. myventr.co is not just about creating events and buying tickets online but is also a place for you to socialise. You can create your own profile, connect with friends or create your own group for your organisation!

How is this different to other social media websites then? Myevent is about connecting people’s social …
Run Code Online (Sandbox Code Playgroud)

iphone ios

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

在上传到服务器之前压缩视频和图像

将图像和视频一起上传到服务器。用户最多可以选择 5 个图像和 5 个视频。所以需要在上传前减小视频和图片的大小。请指导。下面是我正在尝试的。对图像做了一些事情,但不知道视频压缩。

// images

if  let imageData1 = UIImageJPEGRepresentation(User.sharedInstance.arrRoomGalleryImages.objectAtIndex(index) as! UIImage, 0.6) {              
    multipartFormData.appendBodyPart(data: imageData1, name: "image_path[]", fileName: strImgName, mimeType: "image/png")
}
Run Code Online (Sandbox Code Playgroud)

// 视频

let strVidName = "vid" + String(index) // + ".mov"

multipartFormData.appendBodyPart(data: User.sharedInstance.arrRoomGalleryVideos.objectAtIndex(index) as! NSData, name: "video_path[]", fileName: strVidName, mimeType: "application/octet-stream")
Run Code Online (Sandbox Code Playgroud)

iphone video upload ios swift

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

直接点击按钮打开 DatePicker 弹出窗口

尝试在按钮点击时打开日期选择器弹出窗口,但它显示标签而不是选择器,并且在点击该标签时,选择器将打开。下面是代码:

 @IBAction func changeMonth(_ sender: Any) {
     
    let picker : UIDatePicker = UIDatePicker()
    picker.datePickerMode = UIDatePicker.Mode.date
    picker.addTarget(self, action: #selector(dueDateChanged(sender:)), for: UIControl.Event.valueChanged)
        let pickerSize : CGSize = picker.sizeThatFits(CGSize.zero)
        picker.frame = CGRect(x:0.0, y:250, width:pickerSize.width, height:460)
        
        self.view.addSubview(picker)
}

@objc func dueDateChanged(sender:UIDatePicker){
    let dateFormatter = DateFormatter()
    dateFormatter.dateStyle = .none
    dateFormatter.timeStyle = .none
btnMonth.setTitle(dateFormatter.string(from: sender.date), for: .normal)
}
Run Code Online (Sandbox Code Playgroud)

需要通过点击按钮来打开:

在此输入图像描述

但这正在显示:

在此输入图像描述

点击此日期标签后,选择器将打开。我不明白为什么选择器不直接打开。请指导上面的代码有什么问题。

uidatepicker ios swift

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

如何以特定格式获得一年中的所有月份

如何以一种特殊格式"2013年1月"等表格视图获取一年中的所有月份.我也需要设置起始月份.以下是我试过的代码.

int mCurrentMonth = [dateComponents month];
int mCurrentYear = [dateComponents year];

NSString * dateString = [NSString stringWithFormat: @"%d",mCurrentMonth];

NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM"];
NSDate* myDate = [dateFormatter dateFromString:dateString];

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMMM"];
NSString *stringFromDate = [formatter stringFromDate:myDate];
NSString *mon = [NSString stringWithFormat:@"%@ %d",stringFromDate, mCurrentYear];
NSLog(@"month:%@", mon);
Run Code Online (Sandbox Code Playgroud)

上面的代码只给出了我当前所需格式的月份.我试过的其他方式就是这个

NSDateFormatter *df = [[NSDateFormatter alloc] init];

for (int i = 0; i < 12; i++){
    NSString *monthName = [[df monthSymbols] objectAtIndex:i];
    NSLog(@"months name:%@", monthName);
}
Run Code Online (Sandbox Code Playgroud)

这样,我得到所有月份的名字,但不是一年.我没有得到如何实现2013年2月2013年等所需的输出.

nsdate nsdateformatter ios

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

UICollectionViewCell 动态宽度和固定高度

我需要制作椭圆形的 UICollectionView 单元格,其中高度是固定的,但宽度是动态的,并且它也有限制,如果文本长于该值,则文本应该滚动。任何可用于此的第三方选项或需要使用 UICollectionView 创建自己的选项。请指导。

在此处输入图片说明

下面是我想要实现的图像。我想知道在开始之前我应该​​寻找第三方还是使用 UICollectionView 来制作自己的。我有很短的时间来完成这就是为什么要避免在开始时询问自己要遵循的方向的时间。请指导。

gridview ios uicollectionview ios11 xcode9

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

在UITextView中创建文本超链接或可单击

UITextView从三个标签(message,titleUrl和url)中显示并显示文本.我需要的是,我想让"titleUrl"文本可点击以在Web视图中打开"url"的值.我设法直接从网址打开链接,但我需要点击"titleUrl"打开链接.我试图从这段代码中实现以下功能.

[self buildAgreeTextViewFromString:NSLocalizedString(@"I agree to the #<ts>terms of service# and #<pp>privacy policy#", 
                                                 @"PLEASE NOTE: please translate \"terms of service\" and \"privacy policy\" as well, and leave the #<ts># and #<pp># around your translations just as in the English version of this message.")];
Run Code Online (Sandbox Code Playgroud)

但我不知道如何修改它来实现功能.我想在字符串中输入值,没有要输入的静态文本.任何人都可以指导我处理这件事吗?

更新:

NSString *message = [NSString stringWithFormat:@"%@\n ", tempStr1];
        NSString *message1 = [NSString stringWithFormat:@"\n#<pp>%@#", titlStr1];
        NSString *localizedString = NSLocalizedString(message1, nil);

        NSRange ppRange = [localizedString rangeOfString:NSLocalizedString(message1, nil) options:NSCaseInsensitiveSearch];


        NSURL *ppURL = [NSURL URLWithString:strUrl];



        NSDictionary *attribute1 = @{NSForegroundColorAttributeName: …
Run Code Online (Sandbox Code Playgroud)

iphone uitextview ios

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

“GIDSignIn”类型的值没有成员“signInSilently”

这是什么错误,请指导到目前为止在谷歌上找不到任何材料。下面是我的代码,它给出了错误:

if GIDSignIn.sharedInstance().hasAuthInKeychain() == false {
               GIDSignIn.sharedInstance().signIn()
           } else {
               if let user = GIDSignIn.sharedInstance().currentUser {
                   service.authorizer = user.authentication.fetcherAuthorizer()
                   fetchEvents()
               } else {
                   GIDSignIn.sharedInstance().signInSilently()
               }
           }
Run Code Online (Sandbox Code Playgroud)

出现两个错误:

Value of type 'GIDSignIn' has no member 'hasAuthInKeychain'
Value of type 'GIDSignIn' has no member 'signInSilently'
Run Code Online (Sandbox Code Playgroud)

iphone google-calendar-api ios gidsignin swift5

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