小编use*_*452的帖子

iOS 16 后 UIStackView 关于 TitleView 间距问题

我在我的应用程序中导航栏的标题视图上设置了 UIStackView。它只是在标题左侧显示应用程序的图标。在 iOS 15 及更早版本中,这显示得很好。然而,现在,当您第一次启动应用程序时,它显示得很好,但是导航到不同的视图时,图标位于该视图的错误位置,并且当返回到父视图时也会位于错误的位置。其图片位于代码下方。

- (void)viewWillAppear:(BOOL)animated
 UIImageView *theimageView = [[UIImageView alloc] init];
    theimageView.contentMode = UIViewContentModeScaleAspectFit;
    theimageView.image = [UIImage imageNamed:nameOfColor];
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.font = [UIFont fontWithName:@"Roboto-Bold" size:16];
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.text = self.title;

    UIStackView *hStack = [[UIStackView alloc] init];
    [hStack addArrangedSubview:theimageView];
    [hStack addArrangedSubview:titleLabel];
    hStack.axis = UILayoutConstraintAxisHorizontal;

 
    self.navigationItem.titleView = hStack;
    [super viewWillAppear:animated];
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 在此输入图像描述

uiimageview uinavigationcontroller viewwillappear ios uistackview

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

如何在iPhone应用程序中拥有2个leftBarButtonItems,并且1是默认的后退按钮?

我想要2个leftBarButtonItems,但保留其中一个项目作为导航控制器的默认后退按钮.我已经建立:

self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:archives, ???, nil];
Run Code Online (Sandbox Code Playgroud)

其中archives是我创建的UIBarButtonItem,但不知道默认的后退按钮要包含在数组中.有什么建议?

iphone xcode uinavigationcontroller uibarbuttonitem

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

配置文件中未启用通过

这是我的步骤.

我使用pass.com.domain.AppName样式创建了一个passtype ID.

我为com.domain.AppName创建了一个App ID.

我在App ID中启用了Passes.

我使用之前创建的应用ID创建了新的配置文件.

我在Xcode中打开了我的项目,将代码签名标识设置为我刚刚创建的配置文件.

我启用了权利,并在传递下,告诉它使用我的配置文件中的权利.

它说通行证没有启用.我究竟做错了什么?

xcode app-id entitlements ios provisioning-profile

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

在UICollectionView Cell下添加UILabel

我有一个显示图像的UICollectionView,类似于封面艺术或iBooks.我希望它能在UIImageView下面显示音频剪辑的标题.我在我的MainWindow.xib中有一个视图控制器,里面有一个UICollectionView.我还为单元格本身构建了一个NibCell.xib.在Cell中,我有一个UIImageView,它可以填充除了底部30 px的所有细胞.在这个区域我添加了一个UILabel.我给UIImageView标签100和UILabel标签200,在我的代码中我把:

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

     RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];

    static NSString *cellIdentifier = @"cvCell";

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];

    UIImageView *titleLabel = (UIImageView *)[cell viewWithTag:100];
     UILabel *titleLabel2 = (UILabel *)[cell viewWithTag:200];

           NSString *thearticleImage = entry.articleImage;
               [titleLabel setImageWithURL:[NSURL URLWithString:entry.articleImage] placeholderImage:[UIImage imageNamed:@"icon@2x.png"]];

        [titleLabel2 setText:entry.articleTitle];
        return cell;
}
Run Code Online (Sandbox Code Playgroud)

但是,无论在NibCell.xib中如何设置单元格,都会使UIImageView填充整个单元格,并在其上添加UILabel.有什么建议?

uiimageview uilabel ios uicollectionview uicollectionviewcell

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

iOS AirPlay第二屏幕教程

我正在考虑将AirPlay功能添加到我的一个ViewControllers中.View Controller只显示一个UIWebView.我想要做的是添加一个按钮,将此内容镜像到Apple TV.我知道系统范围的镜像可以完成,但它不会填满整个屏幕,周围都是黑条.我一直在网上搜索,但我发现的大部分内容都是从iOS 5回来并且已经过时了.有人能指出我的教程或插入库的方向会有所帮助吗?我只需要在Apple TV上将一个视图的内容镜像为全屏.

到目前为止,这是我所做的,但我相信它只会创建第二个窗口,而不会在其上放置任何内容.

在AppDelegate中,我为它创建了一个属性:

@property (nonatomic, retain) UIWindow *secondWindow;
Run Code Online (Sandbox Code Playgroud)

在AppDelegate的didFinish方法中,我运行:

 NSNotificationCenter *center = [NSNotificationCenter defaultCenter];

    [center addObserver:self selector:@selector(handleScreenDidConnectNotification:)
                   name:UIScreenDidConnectNotification object:nil];
    [center addObserver:self selector:@selector(handleScreenDidDisconnectNotification:)
                   name:UIScreenDidDisconnectNotification object:nil];
Run Code Online (Sandbox Code Playgroud)

然后在AppDelegate中我有:

- (void)handleScreenDidConnectNotification:(NSNotification*)aNotification
{
    UIScreen *newScreen = [aNotification object];
    CGRect screenBounds = newScreen.bounds;

    if (!self.secondWindow)
    {
        self.secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
        self.secondWindow.screen = newScreen;

        // Set the initial UI for the window.
    }
}

- (void)handleScreenDidDisconnectNotification:(NSNotification*)aNotification
{
    if (self.secondWindow)
    {
        // Hide and then delete the window.
        self.secondWindow.hidden = YES;
        self.secondWindow = …
Run Code Online (Sandbox Code Playgroud)

gnu-screen uiwindow ios airplay apple-tv

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

音频不在AVCaptureSession中录制

我有一个应用程序,当一个视图加载,开始捕获视频和音频,并在完成后,将它记录到应用程序的文档文件夹,以及它运行的iPad的相机胶卷.我已经确定并在会话的输入中添加了音频和视频,但是当我去查看保存的视频时,没有音频.任何人都可以在我的代码中发现任何可以指出问题出在哪里的东西吗?

更新:没有显示任何错误消息.但是,我发现了一个共同点.音频将录制,但仅限于录制时间为10秒或更短.如果它达到11秒,则音频不会录制.

NSLog显示

完成错误:(null)

-(void)viewWillAppear:(BOOL)animated {
    NSDate *today = [NSDate date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"MMM d hh:mm:ss a"];
    // display in 12HR/24HR (i.e. 11:25PM or 23:25) format according to User Settings
    NSString *currentTime = [dateFormatter stringFromDate:today];
    NSError* error4 = nil;
    AVAudioSession* audioSession = [AVAudioSession sharedInstance];
    [audioSession setCategory:AVAudioSessionCategoryAmbient error:&error4];
    OSStatus propertySetError = 0;
    UInt32 allowMixing = true;
    propertySetError |= AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck, sizeof(allowMixing), &allowMixing);

    // Activate the audio session
    error4 = nil;
    if (![audioSession setActive:YES error:&error4]) {
        NSLog(@"AVAudioSession setActive:YES …
Run Code Online (Sandbox Code Playgroud)

audio xcode ios avcapturesession avcapturedevice

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

在iOS App中查看Facebook Live

我想我明白API允许从应用程序直播到Facebook,但是是否可以收听特定用户并在应用程序中查看实时视频?我从来没有见过这样做的应用程序的例子,但只是好奇是否有可能这样做.

facebook facebook-graph-api ios facebook-live-api

6
推荐指数
0
解决办法
450
查看次数

Passbook Entitlements?

我正在使用Passslot服务在应用程序中执行Passes.我将我在Provisioning Profile中创建的PassID上传到Pass插槽.我还需要在Xcode中设置Passbook的权利吗?

entitlements ios passbook passslot

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

AirPlay到Apple TV Fullscreen

目前,我为iPhone/iPad制作的任何应用都可以通过AirPlay镜像到Apple TV.但是,即使在横向模式下,它也只占据屏幕的中央部分,左侧和右侧都是黑色.以Real Racing HD这样的应用程序的方式,将它全部转移到AirPlay全屏是什么?

编辑:根据一个建议,我添加了我正在使用的所有代码,而不是告诉secondWindow正常使用相同的根视图控制器,我设置了一个不同颜色的新VC,看看是否正确设置了机制.它们不是,因为它仍然只是正常的镜像,即使告诉它使用不同的VC.

这是AppDelegate.h

#import <UIKit/UIKit.h>
@class MainView;
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate> {
    UIWindow *window;
    UINavigationController *tabBarController;

}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *tabBarController;
@property (nonatomic, retain) UIWindow *secondWindow;
@end
Run Code Online (Sandbox Code Playgroud)

和AppDelegate.m的相关部分

- (void)checkForExistingScreenAndInitializeIfPresent {
    if ([[UIScreen screens] count] > 1) {
        // Get the screen object that represents the external display.
        UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
        // Get the screen's bounds so that you can create a window …
Run Code Online (Sandbox Code Playgroud)

ios airplay apple-tv

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

为什么 tvOS SearchController 不工作?

这一直有效,直到 tvOS 最近更新为止。有什么想法发生了什么吗?搜索栏仍然存在于应用程序中,它只是直接跳到桌面视图。

当应用程序首次发布时,一切都工作正常,但在某些时候,它就停止工作了。我在控制台中没有收到任何错误,一切都表明它已分配并初始化。

-(void)viewDidLoad {
    [super viewDidLoad];
    _resultsTableController = [[APLResultsTableController alloc] init];
    _searchController = [[UISearchController alloc] initWithSearchResultsController:self.resultsTableController];
    self.searchController.searchResultsUpdater = self;
    [self.searchController.searchBar sizeToFit];
    self.tableView.tableHeaderView = self.searchController.searchBar;

    self.resultsTableController.tableView.delegate = self;
    self.searchController.delegate = self;
    self.searchController.searchBar.delegate = self; // so we can monitor text changes + others


    self.definesPresentationContext = YES;  // know where you want UISearchController to be displayed

}
- (void)viewWillAppear:(BOOL)animated {
    if (self.searchControllerWasActive) {
        self.searchController.active = self.searchControllerWasActive;
        _searchControllerWasActive = NO;

        if (self.searchControllerSearchFieldWasFirstResponder) {
            [self.searchController.searchBar becomeFirstResponder];
            _searchControllerSearchFieldWasFirstResponder = NO;
        }
    }
    NSBundle …
Run Code Online (Sandbox Code Playgroud)

xcode uisearchcontroller tvos

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