Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 党卫军投票(截至目前)如下:。请参阅我在此处添加的注释,该注释将您发送到另一个带有示例代码的答案。谢谢。。为了避免头痛,我只需滚动到任意大的数字,比如100000,然后向右移动。您的方式更好,但是,我们对此投了反对票,赞成将UISemanticConten_Ios_Objective C_Uicollectionview_Right To Left_Uicollectionviewlayout - Fatal编程技术网

Ios 党卫军投票(截至目前)如下:。请参阅我在此处添加的注释,该注释将您发送到另一个带有示例代码的答案。谢谢。。为了避免头痛,我只需滚动到任意大的数字,比如100000,然后向右移动。您的方式更好,但是,我们对此投了反对票,赞成将UISemanticConten

Ios 党卫军投票(截至目前)如下:。请参阅我在此处添加的注释,该注释将您发送到另一个带有示例代码的答案。谢谢。。为了避免头痛,我只需滚动到任意大的数字,比如100000,然后向右移动。您的方式更好,但是,我们对此投了反对票,赞成将UISemanticConten,ios,objective-c,uicollectionview,right-to-left,uicollectionviewlayout,Ios,Objective C,Uicollectionview,Right To Left,Uicollectionviewlayout,党卫军投票(截至目前)如下:。请参阅我在此处添加的注释,该注释将您发送到另一个带有示例代码的答案。谢谢。。为了避免头痛,我只需滚动到任意大的数字,比如100000,然后向右移动。您的方式更好,但是,我们对此投了反对票,赞成将UISemanticContentAttribute响应向上移动。不过非常彻底!救了我!!我只是在部署之夜发现了这个问题,令人惊讶的是,我在tableView单元中也有collectionview。谢谢您的回答。@DougMead为什么使用UISemanticContentA


党卫军投票(截至目前)如下:。请参阅我在此处添加的注释,该注释将您发送到另一个带有示例代码的答案。谢谢。。为了避免头痛,我只需滚动到任意大的数字,比如100000,然后向右移动。您的方式更好,但是,我们对此投了反对票,赞成将UISemanticContentAttribute响应向上移动。不过非常彻底!救了我!!我只是在部署之夜发现了这个问题,令人惊讶的是,我在tableView单元中也有collectionview。谢谢您的回答。@DougMead为什么使用UISemanticContentAttribute会更好?一点也不好。uicollectionview已经支持rtl。许多人在不断更改UISemanticContentAttribute的值时报告了性能问题。当你同时支持rtl和ltr时,这种情况就可能发生。我会投票支持Flipshoriz完全反对LayoutDirection,认为它是最好的解决方案。在那里你可以检查你的应用程序状态。并对某些UICollectionView进行例外。子类化UICollectionViewFlowLayout是解决方案。UISemanticContentAttribute不是最佳解决方案。它说武力是出于某种原因。苹果似乎不是为了这样使用它而创建的。向下投票支持将
UISemanticContentAttribute
响应向上移动,因为你不应该向下投票选择正确的答案。这是一个解决方案,可以很好地处理文本。以前的解决方案对文本不起作用。从技术上讲,这应该是正确的答案。但是-它似乎会停止集合视图批量更新动画的工作(因为转换黑客没有这样做)。您可能需要将UICollectionViewFlowLayout子类化。使用此属性比误用RTL支持更好,RTL支持适用于从右向左阅读的语言。有关此答案的详细信息,请参阅此处:
self.collectionView.collectionViewLayout = [[UICollectionViewRightAlignedLayout alloc] init];
[collectionView_ setTransform:CGAffineTransformMakeScale(-1, 1)];
[self.contentView setTransform:CGAffineTransformMakeScale(-1, 1)];
//in viewDidLoad
    YourCollectionView.transform = CGAffineTransform(scaleX: -1.0, y: 1.0)

//in cellForItemAtIndexPath
    cell.transform = CGAffineTransform(scaleX: -1.0, y: 1.0)
override func viewDidAppear(animated: Bool) {
    if collectionView?.numberOfItemsInSection(0) > 0  {
        let indexPath = NSIndexPath(forItem: 0, inSection: 0)
        collectionView?.scrollToItemAtIndexPath(indexPath, atScrollPosition: .Left, animated: false)
    }
}
class CategoryRow : UITableViewCell {
    @IBOutlet weak var collectionView: UICollectionView!

    override func drawRect(rect: CGRect) {
        super.drawRect(rect)
        scrollToBeginning()
    }

    override func prepareForReuse() {
        scrollToBeginning()
    }

    func scrollToBeginning() {
        guard collectionView.numberOfItems(inSection: 0) > 0 else { return }
        let indexPath = IndexPath(item: 0, section: 0)
        collectionView.scrollToItem(at: indexPath, at: .left, animated: false)
    }
}
YourCollectionView.semanticContentAttribute = UISemanticContentAttribute.forceRightToLeft
extension UICollectionViewFlowLayout {

    open override var flipsHorizontallyInOppositeLayoutDirection: Bool {
        return true
    }

}
class RTLCollectionViewFlowLayout: UICollectionViewFlowLayout {

    override var flipsHorizontallyInOppositeLayoutDirection: Bool {
        return true
    }

    override var developmentLayoutDirection: UIUserInterfaceLayoutDirection {
        return UIUserInterfaceLayoutDirection.rightToLeft
    }
}
[DllImport(ObjCRuntime.Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSend")]
internal extern static IntPtr IntPtr_objc_msgSend(IntPtr receiver, IntPtr selector, UISemanticContentAttribute arg1);
        var selector = new ObjCRuntime.Selector("setSemanticContentAttribute:");
        IntPtr_objc_msgSend(UIView.Appearance.Handle, selector.Handle, UISemanticContentAttribute.ForceRightToLeft);
    [Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
    [DllImport(ObjCRuntime.Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSend")]
    internal extern static IntPtr IntPtr_objc_msgSend(IntPtr receiver, IntPtr selector, UISemanticContentAttribute arg1);


    //
    // This method is invoked when the application has loaded and is ready to run. In this 
    // method you should instantiate the window, load the UI into it and then make the window
    // visible.
    //
    // You have 17 seconds to return from this method, or iOS will terminate your application.
    //
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        global::Xamarin.Forms.Forms.SetFlags("Shell_Experimental", "Visual_Experimental", "CollectionView_Experimental", "FastRenderers_Experimental");
        global::Xamarin.Forms.Forms.Init();
        LoadApplication(new App());

        ...

        var selector = new ObjCRuntime.Selector("setSemanticContentAttribute:");
        IntPtr_objc_msgSend(UIView.Appearance.Handle, selector.Handle, UISemanticContentAttribute.ForceRightToLeft);

        return base.FinishedLaunching(app, options);
    }
}
import UIKit

class RightAlignFlowLayout: UICollectionViewFlowLayout {

    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]?
    {
        guard let attrsArr = super.layoutAttributesForElements(in: rect) else {
            return nil
        }
        guard let collectionView = self.collectionView else { return attrsArr }
        if self.collectionViewContentSize.width > collectionView.bounds.width {
            return attrsArr
        }

        let remainingSpace = collectionView.bounds.width - self.collectionViewContentSize.width

        for attr in attrsArr {
            attr.frame.origin.x += remainingSpace
        }

        return attrsArr
    }

    override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
        guard let attrs = super.layoutAttributesForItem(at: indexPath) else { return nil }
        guard let collectionView = self.collectionView else { return attrs }
        if self.collectionViewContentSize.width > collectionView.bounds.width {
            return attrs
        }

        let remainingSpace = collectionView.bounds.width - self.collectionViewContentSize.width
        attrs.frame.origin.x += remainingSpace
        return attrs
    }

}
extension UICollectionViewFlowLayout {

    open override var flipsHorizontallyInOppositeLayoutDirection: Bool {
        return true
    }

}
extension UICollectionView {
    
    func scrollToEndIfArabic() {
        if Language.shared.isArabic() {
            DispatchQueue.main.async {
                self.contentOffset
                    = CGPoint(x: self.contentSize.width
                        - self.frame.width
                        + self.contentInset.right, y: 0)
            }
        }
    }
}
let LangCheck = PPLocalization.sharedInstance.getLanguage(forAPI: true)
if(LangCheck == "ar"){
   CollectionView.transform = CGAffineTransform(scaleX: -1, y: 1);
}
let LangCheck = PPLocalization.sharedInstance.getLanguage(forAPI: true)
  if(LangCheck == "ar"){
     cell.lbCategoryName.transform = CGAffineTransform(scaleX: -1.0, y: 1.0)
  }