我们可以在图像上设置下面的形状UIImageView.
任何的想法!
谢谢

我目前在iOS中遇到推送通知问题.
我的应用程序收到包含标识符的静默推送通知 然后,此标识符用于从创建本地通知的远程服务器获取数据.
据我所知,如果用户强制退出应用程序(即通过双击主页按钮并轻扫关闭应用程序),则无提示推送通知不会传递到AppDelegate类中的didReceiveRemoteNotification方法[1 ] [2],从而阻止应用程序进行任何类型的处理.
我已经对处理上述情况做了大量研究.然而,无法找到明确的答案,并希望有人可以帮助我或指出我正确的方向.
我厌倦了这样做.让我告诉你发生了什么事.我使用的是iOS 9.0和Xcode 7.3.1.
情况1:
我已经注册了这样的本地通知设置didFinishLaunchingWithOptions.
let settings = UIUserNotificationSettings(forTypes: [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound] , categories: nil)
application.registerUserNotificationSettings(settings)
Run Code Online (Sandbox Code Playgroud)
我的项目中有几个控制器,用户将在其中一个按下一个按钮,我将通过调用函数来安排通知App Delegate.功能如下.
func activatingUserLocalNotification(timeIntervalSinceNow : NSDate?, alertBody : String, userInfo : [NSObject : AnyObject], region : CLRegion?)
{
let localNotification = UILocalNotification()
localNotification.fireDate = timeIntervalSinceNow
localNotification.timeZone = NSTimeZone.defaultTimeZone()
localNotification.alertBody = alertBody
localNotification.region = region
localNotification.regionTriggersOnce = false
localNotification.soundName = UILocalNotificationDefaultSoundName
localNotification.userInfo = userInfo
localNotification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
}
Run Code Online (Sandbox Code Playgroud)
现在我通过按下按钮来设置通知,该按钮调用了上面的功能,它成功地安排了通知.
我在所有这些方法中都设置了断点.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> …Run Code Online (Sandbox Code Playgroud) 最近iOS有iOS 10的更新并且开发人员有一些变化,其中一个变化是现在我们无法检查允许完全访问我们之前做过的方式在下面给出
-(BOOL)isOpenAccessGranted{
return [UIPasteboard generalPasteboard];
}
Run Code Online (Sandbox Code Playgroud)
我搜索了最新的UIPasteboard开发者指南,但无法解决.有没有人有一个适当的解决方案.
我正在尝试布局一些自定义视图,当我尝试激活约束时,Xcode说我不能使用乘数.以下是代码示例:
class MenuView: UIView {
var addButton: AddButton!
var settingsButton: SettingsButton!
// ........
func setConstraints (withBarReference reference: NSLayoutYAxisAnchor) {
NSLayoutConstraints.activateConstraints([
// ........
addButton.centerXAnchor.constraintEqualToAnchor(self.centerXAnchor, multiplier: 0.5),
// ........
settingsButton.centerXAnchor.constraintEqualToAnchor(self.centerXAnchor, multiplier: 1.5)
])
}
}
Run Code Online (Sandbox Code Playgroud)
这里的事情是Xcode在contraintEqualToAnchor:functions上给出语法错误,并说我应该将"multiplier"替换为"constant".
为什么我不能将乘数选项与X中心锚点一起使用?
我正在尝试对 collectionView 中的单元格重新排序,但未调用 collectionView delgate 方法。我已经正确设置了代表。
- (void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(NSIndexPath )sourceIndexPath toIndexPath:(NSIndexPath )destinationIndexPath
这是我的工作代码。
- (void)viewDidLoad {
[super viewDidLoad];
UILongPressGestureRecognizer *longGesture=[[UILongPressGestureRecognizer alloc] init];
[longGesture addTarget:self action:@selector(handleGesture:)];
[self.collectionView addGestureRecognizer:longGesture];
NSLog(@"The array is %@",dataArray);
self.collectionView.delegate=self;
[_collectionView reloadData];
// Do any additional setup after loading the view, typically from a nib.
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [dataArray count];
}
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
MyCollectionViewCell *cell …Run Code Online (Sandbox Code Playgroud) 如果用户在开始时不允许访问相册,我会弹出一个带有取消和设置可供选择的弹出窗口。如果他选择设置,它会将他带到设置页面,在那里他可以为应用程序启用相机和照片库。但是,一旦用户在设置中切换相机或照片库开关,我的应用程序就会崩溃,并显示“来自调试器的消息:由于信号 9 而终止”打印输出。下面是我的弹出窗口的代码
@IBAction func cameraBarBtnPress(sender: AnyObject) {
let photoAuthStatus = PHPhotoLibrary.authorizationStatus()
switch photoAuthStatus {
case .Authorized:
presentFusumaCameraVC()
case .Denied, .Restricted :
showNeedPhotoAlbumAccessPopup()
case .NotDetermined:
PHPhotoLibrary.requestAuthorization({ (authStatus: PHAuthorizationStatus) in
switch authStatus {
case .Authorized:
self.presentFusumaCameraVC()
case .Denied, .Restricted :
self.showNeedPhotoAlbumAccessPopup()
case .NotDetermined:
print("Shouldnt get to here")
}
})
}
}
func showNeedPhotoAlbumAccessPopup() {
let alertController = UIAlertController(title: "Enable Photo Album Access", message: "", preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .Default, handler: nil)
let settingsAction = UIAlertAction(title: "Settings", style: …Run Code Online (Sandbox Code Playgroud) 设置一个PageViewController之后我想删除里面的视图控制器,把它留空.
我怎样才能做到这一点?
我已尝试在viewControllers参数中setViewControllers:direction:animated:completion:传递方法nil或空数组,但它崩溃了.
我怎样才能做到这一点?
我有以下代码:
func sendLucidNotification() {
let content = UNMutableNotificationContent()
content.title = "10 Second Notification Demo"
content.subtitle = "From MakeAppPie.com"
content.body = "Notification after 10 seconds - Your pizza is Ready!!"
content.categoryIdentifier = "message"
}
Run Code Online (Sandbox Code Playgroud)
当我调用,UNMutableNotificationContent或任何"UNMutableNotification"变体时,我收到以下错误:
Use of unresolved identifier: "UNMutableNotificationContent"
Run Code Online (Sandbox Code Playgroud)
我在Xcode 8.0上,但是当我尝试自动完成时,它也无法识别它.有任何想法吗 ?谢谢!
如何在顶部创建一个水平滚动视图,就像一个有很多按钮的滚动菜单(例如:20个按钮)?请帮忙 !
我使用以下代码:
CGRect buttonFrame = CGRectMake(0.0f, 0.0f, scrollView.frame.size.width, scrollView.frame.size.height);
for (NSString *text in wordsArray) {
UIButton *button = [[UIButton alloc]initWithFrame:buttonFrame];
button.text = text;
[scrollView addSubview:button];
buttonFrame.origin.x +=buttonFrame.size.width;
}
CGSize contentSize = scrollView.frame.size;
contentSize.width = buttonFrame.origin.x;
scrollView.contentSize = contentSize;
Run Code Online (Sandbox Code Playgroud)
但没有得到我想要的东西.
ios ×10
objective-c ×7
swift ×4
ios10 ×1
keyboard ×1
uibutton ×1
uiimage ×1
uiimageview ×1
uipasteboard ×1
uiscrollview ×1