小编nyn*_*ohu的帖子

LinearLayoutManager无法解析getOrientation()

我有一个RecyclerView片段实现,我试图在代码中添加分隔符.我RecylcerView按预期工作,但LinearLayoutManager无法解决getOrientation()功能.

private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    View root = (View) inflater.inflate(R.layout.fragment_settings, null);
    getActivity().setTitle("Settings");

    mRecyclerView = (RecyclerView) root.findViewById(R.id.recycler_view_settings);

    mRecyclerView.setHasFixedSize(true);

    mLayoutManager = new LinearLayoutManager(getContext());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new SettingsAdapter(getResources().getStringArray(R.array.setting_list));
    mRecyclerView.setAdapter(mAdapter);
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(), mLayoutManager.getOrientation());
    mRecyclerView.addItemDecoration(dividerItemDecoration);
    return root;
}
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview linearlayoutmanager

13
推荐指数
2
解决办法
4250
查看次数

如何在 RxSwift 中为行编写高度?

我想将以下代码转换为RxSwift. 还请帮助我如何ActionRxSwift.

ReactiveCocoa或者RxSwift哪个更适合在 swift3 中使用?

func tableView(_ tableView: UITableView, numberOfRowsInSection section: 
Int) -> Int {
    return posts.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: 
IndexPath) -> UITableViewCell {
    let cell: BTSTableViewCell = self.tableView.dequeueReusableCell(withIdentifier: "BTSTableViewCellIdentifier")! as! BTSTableViewCell

    cell.configureWithPost(posts[indexPath.row])
    cell.delegate = self
    return cell

}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

    // 259.5+ labelHeight+ bigImageHeight

    let postViewModel = posts[indexPath.row]

    //caption height
    var captionHeight = postViewModel.textDetail?.height(withConstrainedWidth: tableView.bounds.size.width - 20, font: …
Run Code Online (Sandbox Code Playgroud)

ios reactive-cocoa rx-swift swift3

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

反应原生导航中的RCC Manager问题

我试图在反应本机项目中实现react-native-navigation选项卡栏,虽然我一直收到错误:

'undefined不是一个对象(Evaluating RCCManager.setRootController)'.


我首先安装了react-native-navigation,然后是react-native-controllers,然后做了react-native链接(就像教程所说).

这是我的AppDelegate.m代码:

#import "AppDelegate.h"
#import "RCCManager.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings]jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  self.window.backgroundColor = [UIColor whiteColor];
  [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation];

  return YES;
}

@end
Run Code Online (Sandbox Code Playgroud)

ios reactjs react-native react-native-navigation

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

在Xcode 8.1中创建NSManagedObject类,显示错误

NSManagedObject使用edition-> create NSManagedObjectsubclass 在Xcode 8中为实体创建了类.它创建2个文件,一个带+CoreDataProperties扩展名,另一个带+CoreDataClass扩展名.

添加这些文件后出现错误链接器命令失败并显示重复文件...我已检查文件是否在finder和Xcode中添加了两次

如果我CoreDataClass.m从编译源中删除文件错误已经消失,但应用程序崩溃了.我无法访问实体类的属性.怎么解决这个?

core-data objective-c ios

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

如何使用swift清除和重绘UIView(存在于视图控制器中)的内容?

我有一个UIView内部View Controller,我正在绘制我的应用程序所需的几行.经过一段时间后,我希望其中一些线条消失,其他一些线条出现在同一视图中.我现在使用的方法是我正在清除UIView并重新绘制我想要在更新视图中绘制的所有线条.

有人能告诉我什么是正确的方法吗?我已经经历了各种听起来相似的问题,但它没有多大帮助.直到现在我尝试过这样的事情: -

outletView.setNeedsDisplay()
Run Code Online (Sandbox Code Playgroud)

let context = UIGraphicsGetCurrentContext()
context?.clear(outletView.frame)
Run Code Online (Sandbox Code Playgroud)

这些似乎没有任何区别.

如果我viewDidLoad()再次打电话,因为所有线路现在都已更新.要绘制的新线条会出现,但应该消失的线条不会消失.行的变量被正确更新,因为我有其他逻辑检查行变量的值在更新应该发生后工作正常.唯一的问题是重绘部分.事实上,如果我理解正确,问题只是清理旧的uiview内容.如果清洁正常进行,重绘viewDidLoad将显示正确的线条绘制.

PS我知道viewDidLoad()明确打电话不是一个好习惯.希望找到解决此问题的方法,而无需再次调用viewDidLoad.

iphone xcode uiview ios swift

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

ObjectiveC &lt;自定义UI&gt;共享扩展名取消按钮

这可能有些愚蠢,但是我NSExtension为我的应用实现了此共享,该应用具有内置的自定义UI MainInterface.storyboard(已附加图像)。现在的问题是,我如何退出呢?

我试过了:

  • [self.navigationController popViewControllerAnimated:YES];
  • [self dismissViewControllerAnimated:YES completion:nil];
  • [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

..但是它不起作用;

我退出它的唯一方法是:

  • @throw @“”; (我什至认为都不会通过苹果的提交验证。。)

我想念什么?

谢谢。

MainInterface.storyboard

objective-c ios ios8-share-extension

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

AVPlayer-从本地URL播放

令人惊讶的是,尽管进行了很多搜索,但我仍无法找到答案。

我有一个已缓存的文件,我可以检索我认为是url的缓存目录和文件名吗?

这是获取文件然后播放的代码

let cachedFilePath = getCachedFilePath.result as! String
audioFileURL = cachedFilePath
self.audioPlayerItem = AVPlayerItem(url: NSURL(string: audioFileURL!) as! URL)
Run Code Online (Sandbox Code Playgroud)

这是如果我打印返回的内容audioFileURL

/ Users / Genie / Library / Developer / CoreSimulator / Devices / A2FB00CE-B018-4FDF-9635-35FD6678DF8D / data / Containers / Data / Application / E18B5E89-B973-4277-AA5C-1378C69D80CD / Library / Caches / Parse / PFFileCache / 7e4a8f655859 %20Name%20of%20the%20Wind%2017-92.mp3

播放器加载,但从不播放,它只是坐在那里旋转。所以我想知道我是否将URL正确传递给播放器?

我读过一个要使用的线程,file://但是没有用。

ios avplayer swift

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

Fluent Nhibernate如何忽略现有表中的映射列

是否可以将模型中的类映射到具有比模型类更多列的表?我只想使用表映射表的特定列Fluent Nhibernate.例如,表格包含以下列:

ProductId
ProductName
BatchNumber
StoreId
Run Code Online (Sandbox Code Playgroud)

但在模型类中我只想要:ProductId, ProductName. 是否有可能不包括BatchNumberStoreId模型类?

c# nhibernate fluent-nhibernate

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

IBoutlet在我的自定义表格单元格中是否为零?

//自定义单元格在一个swift文件中

import UIKit

class CardTableViewCell: UITableViewCell {

    @IBOutlet weak var elapsedTime: UILabel!
    @IBOutlet weak var todo: UILabel!
    @IBOutlet weak var startAndStop: UIView!
    @IBOutlet weak var progress: UIView!
    @IBOutlet weak var cardView: UIView!

}
Run Code Online (Sandbox Code Playgroud)

//自定义表视图控制器在另一个swift文件中

import UIKit

class CardFeedTableViewController: UITableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.register(CardTableViewCell.self, forCellReuseIdentifier: "cardCell")
        tableView.delegate = self
        tableView.dataSource = self
    }

    // MARK: - Table view data source

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number …
Run Code Online (Sandbox Code Playgroud)

uitableview custom-cell tableviewcell ios swift

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