小编Roc*_*ock的帖子

如何从iphone获取生日列表联系人

ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef nameArray = ABAddressBookCopyArrayOfAllPeople (addressBook);

m_SourceContactsUserArray = [[NSMutableArray alloc] init];
for (int i = 0; i<CFArrayGetCount(nameArray); i++) {
    ABRecordRef person = CFArrayGetValueAtIndex(nameArray, i);
    NSString *personName = (NSString*)ABRecordCopyValue(person,kABPersonFirstNameProperty);
    [m_SourceContactsUserArray addObject:personName];
}
CFRelease(addressBook);
CFRelease(nameArray);
Run Code Online (Sandbox Code Playgroud)

iphone addressbook

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

如何使用Swift修剪视频文件并将其转换为20秒视频?

我要修剪视频文件。我只想从图库中选择视频并将其转换为15秒的视频。我正在使用Objective C的 链接。它对我来说很好用,但我是Swift语言的初学者。谁能帮助我在Swift中转换此代码?

以下是我在Objective C中的代码:

-(void)cropVideo:(NSURL*)videoToTrimURL{
    AVURLAsset *asset = [AVURLAsset URLAssetWithURL:videoToTrimURL options:nil];
    AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *outputURL = paths[0];
    NSFileManager *manager = [NSFileManager defaultManager];
    [manager createDirectoryAtPath:outputURL withIntermediateDirectories:YES attributes:nil error:nil];
    outputURL = [outputURL stringByAppendingPathComponent:@"output.mp4"];
    // Remove Existing File
    [manager removeItemAtPath:outputURL error:nil];

    //
    exportSession.outputURL = [NSURL fileURLWithPath:outputURL];
    exportSession.shouldOptimizeForNetworkUse = YES;
    exportSession.outputFileType = AVFileTypeQuickTimeMovie;
    CMTime start = CMTimeMakeWithSeconds(1.0, 600); // you will modify time range here
    CMTime duration = CMTimeMakeWithSeconds(19.0, 600); …
Run Code Online (Sandbox Code Playgroud)

crop video-processing ios swift2

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

SwiftUI code is working in iphone but blank screen in ipad?

Though application is universal but ipad screen is blank. I have added checked both iphone and ipad. When running app in iphone works fine, but in ipad is not showing anything.

struct UserListView: View {

    var userName:String
    @State var searchString:String = ""

    var body: some View {

        VStack {
            SearchBar(text: $searchString)
                    .padding()
                    .frame(height:44)
                    .foregroundColor(Color.white)
                    .background(Color.gray)

            List(userList) { user  in
                   NavigationLink(destination:UserDetailView(userObj:user)) {

                    UserListRow(userObj: user)
                       }.navigationBarTitle("User Detail")
                    }
           }
      }
}
Run Code Online (Sandbox Code Playgroud)

ipad ios swiftui xcode11

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

NavigationView和导航按钮上的链接单击快速UI?

我正在尝试从登录视图推送到详细信息视图,但无法做到这一点。即使导航栏也未显示在登录视图中。如何在swiftUI中按下按钮单击?如何在单击按钮时使用导航链接?

var body: some View {

    NavigationView {

            VStack(alignment: .leading) {

                     Text("Let's get you signed in.")
                       .bold()
                       .font(.system(size: 40))
                       .multilineTextAlignment(.leading)
                       .frame(width: 300, height: 100, alignment: .topLeading)
                       .padding(Edge.Set.bottom, 50)


                       Text("Email address:")
                           .font(.headline)
                                      TextField("Email", text: $email)
                                       .frame(height:44)
                                       .accentColor(Color.white)
                                       .background(Color(UIColor.darkGray))
                                       .cornerRadius(4.0)

                       Text("Password:")
                                      .font(.headline)

                      SecureField("Password", text: $password)
                                   .frame(height:44)
                                   .accentColor(Color.white)
                                   .background(Color(UIColor.darkGray))
                                   .cornerRadius(4.0)


                       Button(action: {
                           print("login tapped")

                       }) {
                           HStack {
                               Spacer()
                               Text("Login").foregroundColor(Color.white).bold()
                               Spacer()
                           }
                       }
                       .accentColor(Color.black)
                       .padding()
                       .background(Color(UIColor.darkGray))
                       .cornerRadius(4.0)
                       .padding(Edge.Set.vertical, 20)
                   }
                   .padding(.horizontal,30)
           }
            .navigationBarTitle(Text("Login"))
        }  
Run Code Online (Sandbox Code Playgroud)

ios swift swiftui

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

文本标签未根据 ScrollView SwiftUI 中的字符串展开

在此处输入图片说明我只是在滚动视图中添加了 TextLabel,但它仅显示在 1 行中。没有滚动视图,它可以在 Label 的全高度下正常工作

 struct UserDetailView: View {

        var userObj:User?

        var body: some View {
            ScrollView {
                VStack {

                    Text("Hi here is Erick jackson. We need to help you. We will help you. Anything new to learn from you. I am here for that reason.")
                        .background(Color.orange)
                        .multilineTextAlignment(.center)
                    .lineLimit(5)
                }
            }
            .padding(.horizontal,30)
        }
    }
Run Code Online (Sandbox Code Playgroud)

ios swift swiftui

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

标签 统计

ios ×4

swiftui ×3

swift ×2

addressbook ×1

crop ×1

ipad ×1

iphone ×1

swift2 ×1

video-processing ×1

xcode11 ×1