小编Fab*_*ger的帖子

在ViewController中的UICollectionView中刷新以刷新

我在下面使用了以下代码 UICollectionViewController

override func viewDidLoad() {            

    self.collectionView!.alwaysBounceVertical = true
    let refresher = UIRefreshControl()
    refresher.addTarget(self, action: "refreshStream", forControlEvents: .ValueChanged)

    refreshControl = refresher
    collectionView!.addSubview(refreshControl!)
}

func refreshStream() {

    print("refresh")
    self.collectionView?.reloadData()

    refreshControl?.endRefreshing()

}
Run Code Online (Sandbox Code Playgroud)

现在我需要它与UICollectionView内部工作,UIViewController我用Google搜索了一个小时,但无法让它工作.我感谢任何帮助.

ios swift

31
推荐指数
4
解决办法
3万
查看次数

我的应用程序在UIDocumentPickerViewController上崩溃了

我正在研究iOS App上的文件共享,我是新手UIDocumentPickerViewController.我不知道为什么我的应用程序崩溃了.

UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.image"] inMode:UIDocumentPickerModeImport];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

应用程序在突出显示的行上崩溃.

有没有人以前做过这个?我想像下面的附件一样做在此输入图像描述

xcode ios icloud uidocumentpickervc icloud-drive

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

在ios中追加带字符串的字符串

我有一些文本共享到evernote的问题,共享evernote是成功的,但这是我目前的代码情况.我有一个UITableView相应文本的文本和标题.单击共享按钮时,它将一个人共享文本到evernote网站,但标题仍然是静态的.在那里,我得到了第一个标题名称以及不同的文本.我的代码在我的tableview中rowAtIndexPath

NSMutableString *strr=[[NSMutableString alloc]initWithString:[appDelegate.indexArray objectAtIndex:indexPath.section]];
cell.textLabel.text =strr ;
cell.textLabel.text = [appDelegate.indexArray objectAtIndex:row];
cell.textLabel.font = [UIFont fontWithName:@"Georgia" size:14.0]; 
cell.textLabel.textColor = [UIColor brownColor];


[appDelegate.notesArray objectAtIndex:row]];
//cell.detailTextLabel.text =notes;
cell.detailTextLabel.font = [UIFont fontWithName:@"Georgia" size:14.0]; 
cell.detailTextLabel.textColor = [UIColor darkGrayColor];
cell.detailTextLabel.text = [appDelegate.notesArray objectAtIndex:row];
Run Code Online (Sandbox Code Playgroud)

appDelegate.indexArray是每个单元格的标题内容,并appDelegate.notesArray 具有相应标题的文本.

在shareButton中单击:

 NSMutableString *str = [[NSMutableString alloc] initWithString:@"NOTES:"]; 
 for (int i = 0; i<[appDelegate.notesArray count]; i++) { 
        NSString * aString = [[NSString alloc] initWithString:[appDelegate.notesArray objectAtIndex:i]] ;
        NSString * ENML= [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n<en-note>%@",aString]; …
Run Code Online (Sandbox Code Playgroud)

iphone

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

检查设备是否连接到VPN

我可以使用以下方法检查设备是否已连接到互联网:

var connected: Bool = true
var zeroAddress = sockaddr_in()
zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
zeroAddress.sin_family = sa_family_t(AF_INET)
let defaultRouteReachability = withUnsafePointer(&zeroAddress) {
    SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
}
var flags = SCNetworkReachabilityFlags()
if !SCNetworkReachabilityGetFlags(defaultRouteReachability!, &flags) {
    connected = false
}
let isReachable = (flags.rawValue & UInt32(kSCNetworkFlagsReachable)) != 0
let needsConnection = (flags.rawValue & UInt2(kSCNetworkFlagsConnectionRequired)) != 0

if isReachable && !needsConnection && connected {
    login(usernameTextField.text!, password: appPassword.text!, environment: environmentUrl)
} else {
    let alert = UIAlertView()
    alert.title = "No internet connection detected."
    alert.addButtonWithTitle("OK")
    alert.show()

    return …
Run Code Online (Sandbox Code Playgroud)

ios swift

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

如何从iOS中的谷歌地图获取静态图像

我使用google maps api for iOS.我想得到特殊城市的静态图像并将其粘贴到UIImageView中.我该怎么做?

google-maps ios swift

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

在 iOS 中的视频上添加 GIF 水印

我需要完成这个功能:一个视频上有一个GIF叠加,希望能把这个视频和GIF合成一个新的视频。我正在使用以下代码,但结果只是没有 GIF 的视频:

- (void)mixVideoAsset:(AVAsset *)videoAsset {

    LLog(@"Begining");

    NSDate * begin = [NSDate date];

    // 2 - Create AVMutableComposition object. This object will hold your AVMutableCompositionTrack instances.
    AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init];

    // 3 - Video track
    AVMutableCompositionTrack *videoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
                                                                        preferredTrackID:kCMPersistentTrackID_Invalid];
    [videoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration)
                        ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]
                         atTime:kCMTimeZero error:nil];

    // - Audio
    AVMutableCompositionTrack *audioCompositionTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
    AVAssetTrack *audioTrack = [[videoAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
    [audioCompositionTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioTrack.timeRange.duration) ofTrack:audioTrack atTime:kCMTimeZero error:nil];

    // 3.1 - Create AVMutableVideoCompositionInstruction
    AVMutableVideoCompositionInstruction *mainInstruction …
Run Code Online (Sandbox Code Playgroud)

video gif avfoundation calayer ios

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

在UIStackView中对UILabels的隐藏属性进行动画处理会导致不同的动画

UIStackView使用UIView的hidden属性可以非常轻松地创建精美的动画。我有两个UIStackViews每个UILabelsarrangedSubviews当我添加一个新UILabelUIStackView,它应该出现在正确的索引处的标签的动画呈现它,推它上面和下面的标签。

使用UIStackViews以下效果很容易做到:

descriptionLabel.hidden = true 

let count = descriptionStack.arrangedSubviews.count
descriptionStack.insertArrangedSubview(expenseLabel.descriptionLabel, atIndex: count - 1)

UIView.animateWithDuration(0.5) {
  descriptionLabel.hidden = false
}
Run Code Online (Sandbox Code Playgroud)

我想同时针对两个不同的对象执行此效果UIStackViews,但这会导致一些奇怪的行为,其中一个动画正确,而另一个动画从视图顶部掉入。假定可以对其他视图重复上述代码并创建相同的动画:

descriptionLabel.hidden = true 
costLabel.hidden = true

let count = descriptionStack.arrangedSubviews.count
descriptionStack.insertArrangedSubview(expenseLabel.descriptionLabel, atIndex: count - 1)
costStack.insertArrangedSubview(expenseLabel.costLabel, atIndex: count - 1)

UIView.animateWithDuration(0.5) {
  descriptionLabel.hidden = false
  UIView.animateWithDuration(0.5) {
    costLabel.hidden = false
  }
}
Run Code Online (Sandbox Code Playgroud)

在此示例中,costLabel正确设置了动画效果,而descriptionLabel从的顶部插入UIStackView。反转顺序会导致costLabel插入并descriptionLabel正确设置动画。

我尝试了这种动画代码的变体,例如不嵌套动画并使用 …

animation ios animatewithduration uistackview

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

从自定义UITableViewCell获取数据并返回到UITableViewController

我有一个UITableView定制组成UITableViewCells.在每个单元格中,有一个UILabel和一个UISlider.有人知道如何在其中一个滑块的值发生变化时,将滑块的新值从自定义UITableViewCell(在单独的文件中)发送到UITableViewController,以便我可以更新填充表的数组?

到目前为止,我最接近的是失败的黑客攻击:setSelected当滑块值发生变化时触发事件.虽然这突出了更改后的自定义单元格,但事件并未didSelectRowAtIndexPath在中获取UITableViewController.

自定义UITableViewCells 虽然代码总是受到赞赏,但我正在寻找概念/方法解决方案.

杰米,提前谢谢你

uitableview ios swift

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

如何将[CustomClass]转换为[AnyObject]

我有一个自定义类的数组[CustomClass].我想把它转换成[AnyObject].

self.customClassArray = self.anyObjectArray as [AnyObject]
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

'AnyObject'不是'CustomClass'的子类型

无法将'[CustomClass]'类型的值转换为强制类型'[AnyObject]'.

我错过了什么?

arrays ios swift anyobject

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

GMSAutocompletePrediction forecast.attributedFullText不在swift 3.0中给出nsmutablestring

我在swift项目中使用GMSAutocompleteFetcher来搜索地点.在这里,我使用pod安装'GooglePlaces''GooglePlacePicker''GoogleMaps',并在链接https://developers.google.com/places/ios-api/autocomplete#use_the_fetcher中编写所有内容, 但在textFieldDidChange中写入后,我得到的结果是它在委托方法中:

func didAutocomplete(with predictions: [GMSAutocompletePrediction]) {
        let resultsStr = NSMutableString()
        for prediction in predictions {
            resultsStr.appendFormat("%@\n", prediction.attributedFullText)

        }
Run Code Online (Sandbox Code Playgroud)

但在resultsStr得到的价值:

 Ca{
    GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment: 0x608000223940>";
}lifornia{
}
Run Code Online (Sandbox Code Playgroud)

应该是"加利福尼亚"

ios google-places-api swift3 gmsautocomplete

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

在NSObject类中没有调用UIAlertView

我创建了一个NSObject类,我在其中创建了一些常用函数.我创造了展示的功能UIAlertView.它工作正常.但是当我点击警告按钮时,didDismissWithButtonIndex委托方法没有被调用.

+ (void)showMessage:(NSString *)message
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:JMESSAGETITLE message:message delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert postHideAlertNotification:0];
    [alert show];
}


#pragma mark - UIAlertView Delegate

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    NSLog(@"Hello");
}
Run Code Online (Sandbox Code Playgroud)

我不知道问题是什么.

objective-c ios

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

无法分配给属性:'CALayer'是不可变的

我正在尝试CALayer使用以下代码将仿射转换应用于:

var myLayer:CALayer!
myLayer.affineTransform = CGAffineTransformMakeRotation(0)
Run Code Online (Sandbox Code Playgroud)

但我遇到了错误

无法分配给属性:'myLayer'是不可变的.

有什么必要解决这个问题?

calayer affinetransform ios

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

应用程序被拒绝两次但无法在iOS 9.2上重现该问题.我需要帮助识别它

我无法在任何iPhone和iPad上重现这个问题,所有构建在Debug,Release甚至与iTunes一起安装的ad-hoc构建的工作都很好.这是已有应用的更新.从以前版本添加的唯一内容是使用Azure通知中心的通知和版本检查.我正在使用最新版本的Xamarin iOS来创建应用程序

支持的体系结构是ARMv7 + ARM64

我试过了:

  • 运行僵尸乐器
  • 最小化启动负载

崩溃日志的一部分在这里,但我不能做任何事情

Incident Identifier: 533700FF-EE1C-4DFC-AFAD-60FE3600B66D
CrashReporter Key:   9cadde5ef1a33ebb1b6aeeaed6696a7ce8b4087d
Hardware Model:      xxx
Process:             TapNOrder [9390]
Path:                /private/var/mobile/Containers/Bundle/Application/45780C57-DBB0-465C-872F-8A3BE6723261/TapNOrder.app/TapNOrder
Identifier:          biz.innovative-ideas.tapnorder
Version:             0.1.7.2 (0.1.7)
Code Type:           ARM-64 (Native)
Parent Process:      launchd [1]

Date/Time:           2016-01-11 15:00:11.11 -0800
Launch Time:         2016-01-11 15:00:11.11 -0800
OS Version:          iOS 9.2 (13C75)
Report Version:      105

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Triggered by Thread:  0

Filtered syslog:
None found

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 …
Run Code Online (Sandbox Code Playgroud)

c# crash ios xamarin

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